Guest User

Untitled

a guest
Jan 20th, 2019
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.47 KB | None | 0 0
  1. {define form $formName}
  2. <form n:name=$formName>
  3. <ul class=error n:ifcontent>
  4. <li n:foreach="$form->ownErrors as $error">{$error}</li>
  5. </ul>
  6.  
  7. <table>
  8. <tr n:foreach="$form->controls as $input"
  9. n:if="!$input->getOption(rendered) && $input->getOption(type) !== hidden"
  10. n:class="$input->required ? required">
  11.  
  12. <th>{label $input}</th>
  13. <td>{input $input} <span class=error n:ifcontent>{$input->error}</span></td>
  14. </tr>
  15. </table>
  16. </form>
  17. {/define}
  18.  
  19.  
  20. {* for Bootstrap v3 *}
  21. {define bootstrap-form $formName}
  22. <form n:name=$formName class=form-horizontal>
  23. <ul class=error n:ifcontent>
  24. <li n:foreach="$form->ownErrors as $error">{$error}</li>
  25. </ul>
  26.  
  27. <div n:foreach="$form->controls as $name => $input"
  28. n:if="!$input->getOption(rendered) && $input->getOption(type) !== hidden"
  29. n:class="form-group, $input->required ? required, $input->error ? has-error">
  30.  
  31. <div class="col-sm-2 control-label">{label $input}</div>
  32.  
  33. <div class="col-sm-10">
  34. {if $input->getOption(type) in [text, select, textarea]}
  35. {input $input class => form-control}
  36. {elseif $input->getOption(type) === button}
  37. {input $input class => "btn btn-default"}
  38. {elseif $input->getOption(type) === checkbox}
  39. <div class="checkbox">{input $input}</div>
  40. {elseif $input->getOption(type) === radio}
  41. <div class="radio">{input $input}</div>
  42. {else}
  43. {input $input}
  44. {/if}
  45.  
  46. <span class=help-block n:ifcontent>{$input->error ?: $input->getOption(description)}</span>
  47. </div>
  48. </div>
  49. </form>
  50. {/define}
Add Comment
Please, Sign In to add comment