S
S
spido2021-06-06 23:48:47
PHP
spido, 2021-06-06 23:48:47

How to write an if condition for a radio button?

Greetings!
The field in the form is:

<input type="text" id="color_dunkle" name="color_dunkle" class="text" value="{$editable_page.editable_page_theme_config.color_dunkle|default=''}">

When creating new content and when editing already created content, input with
{$editable_page.editable_page_theme_config.color_dunkle|default=''}
works without errors.
If new content is being created, then the value of the color_dunkle parameter is omitted and |default='' is then fired.

I want to convert c input into radio buttons.
To do this, you need to write conditions for the radio buttons.
I wrote such a condition, using the example of one button I will show:
<label for="article_show1" class='{if condition="$editable_page.editable_page_theme_config.color_dunkle eq 1"}selected{/if}'>Да</label>

When editing previously created content - this button works well because the value of the variable has already been created.
But if I want to create new content, I get a 500 error because the value of the variable doesn't exist and I can't attach |default='' to the end of the variable.
How do I attach |default='' to the end of a variable?
It should be like this:
{if condition="$editable_page.editable_page_theme_config.color_dunkle|default='' eq 1"}selected{/if}

Of course, this is not correct and does not work that way, but I do not know how to solve this error correctly.
Thanks in advance to those who respond.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question