sathyashrayan

AttributeFieldset

Aug 5th, 2016
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.35 KB | None | 0 0
  1. <?php
  2. namespace Attributes\Form;
  3.  
  4. use Attributes\Service\AttributeType\AttributeTypeServiceInterface;
  5.  
  6. use Zend\Form\Fieldset;
  7. use Zend\Form\Element;
  8. use Zend\Hydrator\Reflection as ReflectionHydrator;
  9.  
  10. use Attributes\Model\EavAttribute;
  11.  
  12.  
  13. class AttributeFieldset extends Fieldset
  14. {
  15.     private $_attribute_type;
  16.     private $attribute_type_array; // dropdown
  17.     public function __construct(AttributeTypeServiceInterface $attribute_type,$name = null, $options = array())
  18.     {      
  19.         parent::__construct($name , $options );    
  20.        
  21.         $type_list=$attribute_type->findAllAttributesType();
  22.        
  23.         foreach($type_list as $type_list_K => $type_list_V){   
  24.                            
  25.              $id = $type_list_V->getId();
  26.              $name = $type_list_V->getName();
  27.              $this->attribute_type_array[$id] = $name;
  28.         }
  29.        
  30.     }
  31.     public function init(){            
  32.        
  33.         $this->add([
  34.                 'name' => 'eav_validation_type',
  35.                 'attributes' => [
  36.                         'type' => 'text',
  37.                         'size' => '50',
  38.                         'class' => 'form-control',
  39.                 ],
  40.                 'options' => [
  41.                         'label' => 'Validation Type',
  42.                 ],
  43.         ]);
  44.         $this->add([
  45.                 'name' => 'eav_attribute_input_label',
  46.                 'attributes' => [
  47.                         'type' => 'text',
  48.                         'size' => '50',
  49.                         'class' => 'form-control',
  50.                 ],
  51.                 'options' => [
  52.                         'label' => 'Attribute Name',
  53.                 ],
  54.         ]);
  55.        
  56.         $this->add([
  57.                 'name' => 'eav_attribute_code',
  58.                 'attributes' => [
  59.                         'type' => 'text',
  60.                         'size' => '50',
  61.                         'class' => 'form-control',
  62.                 ],
  63.                 'options' => [
  64.                         'label' => 'Attribute Code',
  65.                 ],
  66.         ]);
  67.        
  68.         $this->add([
  69.                 'type' => Element\Select::class,
  70.                 'name' => 'eav_attribute_input_type_id',
  71.                 'options' => [
  72.                         'label' => 'Select an attribute type',
  73.                         'value_options' => $this->attribute_type_array,
  74.                         'empty_option' => "select attribute type"
  75.                 ],
  76.         ]);
  77.        
  78.         $this->add(array(
  79.                 'type'  => 'Zend\Form\Element\Radio',
  80.                 'name'  => 'is_required',
  81.                 'options' => array(
  82.                         'label' => 'values required?',
  83.                         'value_options' => array(
  84.                                 '0' => 'Yes',
  85.                                 '1' => 'No',
  86.                         ),
  87.                 ),
  88.         ));
  89.        
  90.         $this->add(array(
  91.                 'type'  => 'Zend\Form\Element\Radio',
  92.                 'name'  => 'eav_attribute_unique',
  93.                 'options' => array(
  94.                         'label' => 'Unique Value?',
  95.                         'value_options' => array(
  96.                                 '0' => 'Yes',
  97.                                 '1' => 'No',
  98.                         ),
  99.                 ),
  100.         ));
  101.        
  102.         $this->add(array(
  103.                 'type'  => 'Zend\Form\Element\Radio',
  104.                 'name'  => 'can_product_display',
  105.                 'options' => array(
  106.                         'label' => 'Add to product display?',
  107.                         'value_options' => array(
  108.                                 '0' => 'Yes',
  109.                                 '1' => 'No',
  110.                         ),
  111.                 ),
  112.         ));
  113.        
  114.         $this->add(array(
  115.                 'type'  => 'Zend\Form\Element\Radio',
  116.                 'name'  => 'can_use_filter',
  117.                 'options' => array(
  118.                         'label' => 'Use as filter?',
  119.                         'value_options' => array(
  120.                                 '0' => 'Yes',
  121.                                 '1' => 'No',
  122.                         ),
  123.                 ),
  124.         ));
  125.        
  126.         $this->add(array(
  127.                 'type'  => 'Zend\Form\Element\Radio',
  128.                 'name'  => 'can_search',
  129.                 'options' => array(
  130.                         'label' => 'Can us in search?',
  131.                         'value_options' => array(
  132.                                 '0' => 'Yes',
  133.                                 '1' => 'No',
  134.                         ),
  135.                 ),
  136.         ));
  137.        
  138.         $this->add([
  139.                 'name' => 'default_value',
  140.                 'attributes' => [
  141.                         'type' => 'text',
  142.                         'size' => '50',
  143.                         'class' => 'form-control',
  144.                 ],
  145.                 'options' => [
  146.                         'label' => 'Default Value',
  147.                 ],
  148.         ]);
  149.        
  150.        
  151.     }
  152. }
Add Comment
Please, Sign In to add comment