Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <div class="b-form">
- <table class="t-form">
- <tbody>
- <?php foreach ($form->getFields() as $field): ?>
- <?php if (FormField::TYPE_HIDDEN != $field->getType()): ?>
- <tr id="field_<?php echo $field->getName(); ?>"<?php if ($field->hasViolation()): ?> class="error"<?php endif; ?>>
- <td class="field-name"><label for="<?php echo $field->getName(); ?>"><?php echo $form[$field->getName()]->renderLabel(); ?></label><?php if ($field->required()): ?> <span style="color: rgb(150, 50, 50);">*</span><?php endif; ?></td>
- <td class="field-value">
- <?php echo $form[$field->getName()]->render(); ?>
- <?php if ($field->hasDescription()): ?>
- <div class="hint">
- <?php if ($field->hasMinLenght() && $field->hasMaxLenght()): ?>
- <?php echo __($field->getDescription(), array('%MIN%' => $field->getMinLenght(), '%MAX%' => $field->getMaxLenght())); ?>
- <?php else: ?>
- <?php echo __($field->getDescription()); ?>
- <?php endif; ?>
- </div>
- <?php endif; ?>
- <?php if ($field->hasViolation()): ?>
- <div class="hint error-hint"><?php echo __($field->getViolation()); ?></div>
- <?php endif; ?>
- </td>
- </tr>
- <?php else:?>
- <?php echo $form[$field->getName()]->render(); ?>
- <?php endif; ?>
- <?php endforeach; ?>
- </tbody>
- </table>
- <?php echo $form['_csrf_token']; ?>
- <script type="text/javascript">
- $('input[name="contactInformation[clientType]"]').change(function () {
- if ($('input[name="contactInformation[clientType]"]:checked').val() == 1) {
- $('#field_clientCompany').show();
- } else {
- $('#field_clientCompany').hide();
- }
- });
- if ($('input[name="contactInformation[clientType]"]:checked').val() == 1) {
- $('#field_clientCompany').show();
- } else {
- $('#field_clientCompany').hide();
- }
- function updateCountyList(value) {
- var state = $('#contactInformation_contactState').val();
- $.ajax({
- url: '<?php echo url_for('@county-list'); ?>?state=' + state,
- cache: false
- }).done(function(res) {
- clearCountyList();
- res = $.parseJSON(res);
- if (null == res) {
- return;
- }
- var select = $('#contactInformation_contactCounty');
- $.each(res, function(i, option) {
- select.append(
- $('<option></option>').val(option).html(option)
- );
- });
- if ('undefined' != typeof value && '' != value) {
- select.val(value);
- }
- });
- }
- function clearCountyList(){
- $('#contactInformation_contactCounty').children().remove();
- }
- $('#contactInformation_contactState').change(function() {updateCountyList();});
- $(window).ready(function() {
- <?php
- $defaults = $form->getValues();
- $defaultCounty = isset($defaults['contactCounty']) ? $defaults['contactCounty'] : '';
- ?>
- updateCountyList('<?php echo $defaultCounty; ?>');
- });
- </script>
- </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement