_struct_form.php 2.4 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
38
39
40
41
42
43
44
<?php
echo '<form method="post" action="' . $link . '">';
if(!$form->getObject()->isNew()){
    echo '<input name="sf_method" value="put" type="hidden" />';
}
echo '<input id="form_parentId" type="hidden" name="parentId" value="' . $parent_id . '"/>';
echo '<table width="100%" cellpadding="0" cellspacing="0">';
echo '<tr>';
echo '<td style="border-bottom: 1px solid rgba(0, 0, 0, .15);"><div class="a_list__batch_actions"><button onclick="checkTranslate();" style="margin: 10px !important;" type="submit">Сохранить</button></div></td>';
echo '<td style="border-bottom: 1px solid rgba(0, 0, 0, .15);padding-right: 10px;" width="1">';
if(!$form->getObject()->isNew()){
    echo '<a style="border:none;" onclick="if (confirm(\'Вы уверены что хотите удалить объект?\')) {aStruct.delete(this);};return false;" href="' . $link . '" data-csrf="' . $form->getCSRFToken() . '" data-parent_id="' . $parent_id . '"><img src="/i/arm/icon-delete.png" width="16" height="16"></a>';
}
echo '</td></tr>';
$product_detail_class = ($form->getName() == 'product' && ($form->isNew() || $form->getObject()->getIsDetail()) ? ' a_form_product_is_detail' : '');
echo '<tr><td colspan="2" valign="top"><div class="a_form a_form_' . $form->getName() . $product_detail_class . '">';
echo $form->renderHiddenFields();
echo $form->renderGlobalErrors();
foreach ($form as $name => $field){
    if(!$field->isHidden()){
        echo '<div class="sf_admin_form_row sf_admin_form_field_' . $name . ' a_form__' . $name . '">';
        $opts = $field->getWidget()->getOptions();
        if(isset($opts['type']) && $opts['type'] == 'checkbox'){
            $attributes = $field->getWidget()->getAttributes();
            $attributes = ($attributes instanceof sfOutputEscaper ? $attributes->getRawValue() : $attributes);
            echo '<div class="content"><label>' . $field->render($attributes) . $opts['label'] . '</label></div>';
        }else{
            echo '<span class="inline-label">' . $field->renderLabel() . '</span>';
            echo '<div class="content">';
            echo $field->render() . $field->renderError();
            echo '</div>';
        }
        echo '</div>';
    }
}
if($form->getName() == 'product'){
    echo '<div class="sf_admin_form_row a_form__product_props">';
    include_partial('product/props', array('form' => $form));
    echo '</div>';
}
echo '</div></td></tr>';
echo '</table>';
echo '</form>';
?>