Version: current

     1 <?php
     2 // Виджет заказа обратного звонка - показываем выбранную UserDefinedForm
     3 class CallBackWidget extends SidebarWidget {
     4
     5     static $has_one = array(
     6         'Holder' => 'UserDefinedForm',
     7         'Image' => 'Image',
     8     );
     9
    10     public $needObjects = array(
    11         'UserDefinedForm' => 'Page'
    12     );
    13
    14     function getCMSFields() {
    15         if (!$this->canCreate()) {
    16             return $this->getFailCMSFields();
    17         }
    18
    19         $fields = parent::getCMSFields();
    20         $holders = DataObject::get('UserDefinedForm');
    21         if ($holders) {
    22             $holders = $holders->map();
    23         } else {
    24             $holders = array();
    25         }
    26         $fields->addFieldToTab('Root.Main', new DropdownField("HolderID", $this->fieldLabel('Holder'), $holders));
    27         return $fields;
    28     }
    29
    30     function WidgetForm() {
    31         if ($this->HolderID && $this->Holder()) {
    32             $form = $this->Holder();
    33             $controller = new UserDefinedForm_Controller($form);
    34             $controller->init();
    35             return $controller->Form();
    36         }
    37         return false;
    38     }
    39 }
    40
    41

[Raise a SilverStripe Framework issue/bug](https://github.com/silverstripe/silverstripe-framework/issues/new)
- [Raise a SilverStripe CMS issue/bug](https://github.com/silverstripe/silverstripe-cms/issues/new)
- Please use the Silverstripe Forums to ask development related questions. -