R
R
ragnar_ok2019-02-05 08:33:23
1C-Bitrix
ragnar_ok, 2019-02-05 08:33:23

How to display the default value of a property?

A component with a feedback form has been developed (receives the data left by the user in the inputs and enters them into the info block). I display on the page through bitrix:news.list. You need to add a new property with a binding to the user. In this case, if VALUEthe property is empty, you need to display "Application is open". However, the logic of the component is such that if VALUEthe property is empty, then DISPLAY_PROPERTIESit does not fall into it. I think the most correct approach is:

  • Create a property of type "String";
  • Set <input type="hidden">from namethis property and value="Заявка открыта", and thus add an element to DISPLAY_PROPERTIES;
  • Then display it on the page and add the ability to change the value of the property using CIBlockElement::Updatethe user ID;

How to display the default value of a property?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
ragnar_ok, 2019-02-05
@ragnar_ok

I borrowed this approach from the component controller. In case the DEFAULT_VALUE property is filled, it also contributes to DISPLAY_PROPERTIES.

foreach($arResult["ITEMS"] as &$arItem)
{
    foreach($arParams["PROPERTY_CODE"] as &$pid)
    {
        $prop = $arItem["PROPERTIES"][$pid];
        if(
            (is_array($prop["DEFAULT_VALUE"]) && count($prop["DEFAULT_VALUE"])>0)
            || (!is_array($prop["DEFAULT_VALUE"]) && strlen($prop["DEFAULT_VALUE"])>0)
        )
        {
            $arItem["DISPLAY_PROPERTIES"][$pid] = CIBlockFormatProperties::GetDisplayValue($arItem, $prop, "news_out");
        }
    }
}
unset($arItem, $pid);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question