Reputation: 1153
Cannot write class attribute in php file for html element. Here is my code
echo '<div><p class="'.($value->getIsRequire() == 1) ? 'required' : ''.'">
</p> <input type="text" name="field" id="option-value" /></div>';
My output should be if the condition is true the class should be required otherwise the class should be empty but i got output as required text instead of input box.
Result I got is
Upvotes: 0
Views: 1131
Reputation: 783
try this, you should wrap it in parentheses :
echo '<div><p class="'.(($value->getIsRequire() == 1) ? 'required' : '').'">
</p> <input type="text" name="field" id="option-value" /></div>';
Upvotes: 1