_form_field.php 2.12 KB
Newer Older
Яков's avatar
first  
Яков committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?php if ($field->isPartial()): ?>
  <?php include_partial('discount_phone/'.$name, array('form' => $form, 'attributes' => $attributes instanceof sfOutputEscaper ? $attributes->getRawValue() : $attributes)) ?>
<?php elseif ($field->isComponent()): ?>
  <?php include_component('discount_phone', $name, array('form' => $form, 'attributes' => $attributes instanceof sfOutputEscaper ? $attributes->getRawValue() : $attributes)) ?>
<?php else: ?>
  <div class="<?php echo $class ?><?php $form[$name]->hasError() and print ' errors' ?>">
    <div>
      <?php $opts = $form[$name]->getWidget()->getOptions(); ?>
      <?php if (key_exists('type', $opts) && $opts['type'] == 'checkbox'): ?>
        <div class="content"><label><?php echo $form[$name]->render($attributes instanceof sfOutputEscaper ? $attributes->getRawValue() : $attributes); ?><?php echo $label; ?></label></div>
      <?php else: ?>
        <span class="inline-label"><?php echo $form[$name]->renderLabel($label) ?></span>
        <div class="content">
          <?php echo $name == 'url' ? 'http://'.$this->context->getRequest()->getHost().'/ru/discount/' : ''; ?> <?php echo $form[$name]->render($attributes instanceof sfOutputEscaper ? $attributes->getRawValue() : $attributes) ?><?php echo ($name == 'url' ? '/ ' : '') ?> <?php echo ( $name == 'url' && !$form->isNew() ? '<div style="margin-left: 10px !important;" class="pseudo_button lui_pseudo pseudo_button_file_wrapper only_root_button" >Скопировать в буфер обмена</div>' : ''); ?>
          <?php echo $form[$name]->renderError() ?>
          <?php if ($help): ?><span class="help"><?php echo __($help, array(), 'messages') ?></span><?php elseif ($help = $form[$name]->renderHelp()): ?><span class="help"><?php echo strip_tags($help, '<a><i>') ?></span><?php endif; ?>
        </div>
      <?php endif; ?>
    </div>
  </div>
<?php endif; ?>
<?php
if ($name == 'url') {
    ?>
    <script>
        $('.pseudo_button').on('click', function (e) {
            try {

            }
                document.execCommand('copy');
            } catch(err) {
                console.log('Can`t copy');
        })
    </script>
<?php
}
?>