Advertisement
Guest User

Untitled

a guest
Mar 8th, 2014
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.23 KB | None | 0 0
  1. <div class="b-form">
  2. <table class="t-form">
  3. <tbody>
  4. <?php foreach ($form->getFields() as $field): ?>
  5. <?php if (FormField::TYPE_HIDDEN != $field->getType()): ?>
  6. <tr id="field_<?php echo $field->getName(); ?>"<?php if ($field->hasViolation()): ?> class="error"<?php endif; ?>>
  7. <td class="field-name"><label for="<?php echo $field->getName(); ?>"><?php echo $form[$field->getName()]->renderLabel(); ?></label><?php if ($field->required()): ?>&nbsp;<span style="color: rgb(150, 50, 50);">*</span><?php endif; ?></td>
  8. <td class="field-value">
  9. <?php echo $form[$field->getName()]->render(); ?>
  10. <?php if ($field->hasDescription()): ?>
  11. <div class="hint">
  12. <?php if ($field->hasMinLenght() && $field->hasMaxLenght()): ?>
  13. <?php echo __($field->getDescription(), array('%MIN%' => $field->getMinLenght(), '%MAX%' => $field->getMaxLenght())); ?>
  14. <?php else: ?>
  15. <?php echo __($field->getDescription()); ?>
  16. <?php endif; ?>
  17.  
  18. </div>
  19. <?php endif; ?>
  20. <?php if ($field->hasViolation()): ?>
  21. <div class="hint error-hint"><?php echo __($field->getViolation()); ?></div>
  22. <?php endif; ?>
  23. </td>
  24. </tr>
  25. <?php else:?>
  26. <?php echo $form[$field->getName()]->render(); ?>
  27. <?php endif; ?>
  28. <?php endforeach; ?>
  29. </tbody>
  30. </table>
  31. <?php echo $form['_csrf_token']; ?>
  32. <script type="text/javascript">
  33. $('input[name="contactInformation[clientType]"]').change(function () {
  34. if ($('input[name="contactInformation[clientType]"]:checked').val() == 1) {
  35. $('#field_clientCompany').show();
  36. } else {
  37. $('#field_clientCompany').hide();
  38. }
  39. });
  40. if ($('input[name="contactInformation[clientType]"]:checked').val() == 1) {
  41. $('#field_clientCompany').show();
  42. } else {
  43. $('#field_clientCompany').hide();
  44. }
  45.  
  46. function updateCountyList(value) {
  47. var state = $('#contactInformation_contactState').val();
  48. $.ajax({
  49. url: '<?php echo url_for('@county-list'); ?>?state=' + state,
  50. cache: false
  51. }).done(function(res) {
  52. clearCountyList();
  53. res = $.parseJSON(res);
  54. if (null == res) {
  55. return;
  56. }
  57. var select = $('#contactInformation_contactCounty');
  58. $.each(res, function(i, option) {
  59. select.append(
  60. $('<option></option>').val(option).html(option)
  61. );
  62. });
  63. if ('undefined' != typeof value && '' != value) {
  64. select.val(value);
  65. }
  66. });
  67. }
  68.  
  69. function clearCountyList(){
  70. $('#contactInformation_contactCounty').children().remove();
  71. }
  72.  
  73. $('#contactInformation_contactState').change(function() {updateCountyList();});
  74. $(window).ready(function() {
  75. <?php
  76. $defaults = $form->getValues();
  77. $defaultCounty = isset($defaults['contactCounty']) ? $defaults['contactCounty'] : '';
  78. ?>
  79. updateCountyList('<?php echo $defaultCounty; ?>');
  80. });
  81. </script>
  82. </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement