コード例 #1
0
ファイル: FormField.php プロジェクト: kyxer/barriosLaravel
 /**
  * @param array $options
  * @param bool  $showLabel
  * @param bool  $showField
  * @param bool  $showError
  * @return string
  */
 public function render(array $options = [], $showLabel = true, $showField = true, $showError = true)
 {
     $val = null;
     $value = array_get($options, $this->valueProperty);
     $defaultValue = array_get($options, $this->defaultValueProperty);
     if ($showField) {
         $this->rendered = true;
     }
     // Check if default value is passed to render function from view.
     // If it is, we save it to a variable and then override it before
     // rendering the view
     if ($value) {
         $val = $value;
     } elseif ($defaultValue && !$this->getOption($this->valueProperty)) {
         $val = $defaultValue;
     }
     $options = $this->prepareOptions($options);
     if ($val) {
         $options[$this->valueProperty] = $val;
     }
     if (!$this->needsLabel($options)) {
         $showLabel = false;
     }
     if ($showError) {
         $showError = $this->parent->haveErrorsEnabled();
     }
     return $this->formHelper->getView()->make($this->template, ['name' => $this->name, 'nameKey' => $this->getNameKey(), 'type' => $this->type, 'options' => $options, 'showLabel' => $showLabel, 'showField' => $showField, 'showError' => $showError])->render();
 }
コード例 #2
0
ファイル: Form.php プロジェクト: zgao4/laravel-form-builder
    /**
     * Render the form
     *
     * @param $options
     * @param $fields
     * @param boolean $showStart
     * @param boolean $showFields
     * @param boolean $showEnd
     * @return string
     */
    protected function render($options, $fields, $showStart, $showFields, $showEnd)
    {
        $formOptions = $this->formHelper->mergeOptions($this->formOptions, $options);

        $this->setupNamedModel();

        return $this->formHelper->getView()
            ->make($this->formHelper->getConfig('form'))
            ->with(compact('showStart', 'showFields', 'showEnd'))
            ->with('formOptions', $formOptions)
            ->with('fields', $fields)
            ->with('model', $this->getModel())
            ->with('exclude', $this->exclude)
            ->render();
    }
コード例 #3
0
ファイル: FormField.php プロジェクト: Abdulhmid/wecan
 /**
  * @param array $options
  * @param bool  $showLabel
  * @param bool  $showField
  * @param bool  $showError
  * @return string
  */
 public function render(array $options = [], $showLabel = true, $showField = true, $showError = true)
 {
     $this->prepareOptions($options);
     $value = $this->getValue();
     $defaultValue = $this->getDefaultValue();
     if ($showField) {
         $this->rendered = true;
     }
     // Override default value with value
     if (!$this->isValidValue($value) && $this->isValidValue($defaultValue)) {
         $this->setOption($this->valueProperty, $defaultValue);
     }
     if (!$this->needsLabel()) {
         $showLabel = false;
     }
     if ($showError) {
         $showError = $this->parent->haveErrorsEnabled();
     }
     return $this->formHelper->getView()->make($this->getViewTemplate(), ['name' => $this->name, 'nameKey' => $this->getNameKey(), 'type' => $this->type, 'options' => $this->options, 'showLabel' => $showLabel, 'showField' => $showField, 'showError' => $showError])->render();
 }