FOF30\Form\Form::getAttribute PHP Метод

getAttribute() публичный Метод

Returns the value of an attribute of the form itself
С версии: 2.0
public getAttribute ( string $attribute, mixed $default = null ) : mixed
$attribute string The name of the attribute
$default mixed Optional default value to return
Результат mixed
    public function getAttribute($attribute, $default = null)
    {
        $value = $this->xml->attributes()->{$attribute};
        if (is_null($value)) {
            return $default;
        } else {
            return (string) $value;
        }
    }

Usage Example

Пример #1
0
 /**
  * Returns the rendered view template
  *
  * @return string
  */
 protected function getRenderedTemplate($isRepeatable = false)
 {
     $sourceTemplate = isset($this->element['source']) ? (string) $this->element['source'] : null;
     $sourceView = isset($this->element['source_view']) ? (string) $this->element['source_view'] : null;
     $sourceViewType = isset($this->element['source_view_type']) ? (string) $this->element['source_view_type'] : 'html';
     $sourceComponent = isset($this->element['source_component']) ? (string) $this->element['source_component'] : null;
     if (empty($sourceTemplate)) {
         return '';
     }
     $sourceContainer = empty($sourceComponent) ? $this->form->getContainer() : Container::getInstance($sourceComponent);
     if (empty($sourceView)) {
         $viewObject = new View($sourceContainer, array('name' => 'FAKE_FORM_VIEW'));
     } else {
         $viewObject = $sourceContainer->factory->view($sourceView, $sourceViewType);
     }
     $viewObject->populateFromModel($this->form->getModel());
     return $viewObject->loadAnyTemplate($sourceTemplate, array('model' => $isRepeatable ? $this->item : $this->form->getModel(), 'form' => $this->form, 'formType' => $this->form->getAttribute('type', 'edit'), 'fieldValue' => $this->value, 'fieldElement' => $this->element));
 }
All Usage Examples Of FOF30\Form\Form::getAttribute