original_string: protected function makeFormFieldWidget($field)
      {
          if ($field->type !== 'widget') {
              return null;
          }
  
          if (isset($this->formWidgets[$field->fieldName])) {
              return $this->formWidgets[$field->fieldName];
          }
  
          $widgetConfig = $this->makeConfig($field->config);
          $widgetConfig->alias = $this->alias . studly_case(HtmlHelper::nameToId($field->fieldName));
          $widgetConfig->sessionKey = $this->getSessionKey();
          $widgetConfig->previewMode = $this->previewMode;
          $widgetConfig->model = $this->model;
          $widgetConfig->data = $this->data;
          $widgetConfig->parentForm = $this;
  
          $widgetName = $widgetConfig->widget;
          $widgetClass = $this->widgetManager->resolveFormWidget($widgetName);
  
          if (!class_exists($widgetClass)) {
              throw new ApplicationException(Lang::get(
                  'backend::lang.widget.not_registered',
                  ['name' => $widgetClass]
              ));
          }
  
          $widget = $this->makeFormWidget($widgetClass, $field, $widgetConfig);
  
          /*
           * If options config is defined, request options from the model.
           */
          if (isset($field->config['options'])) {
              $field->options(function () use ($field) {
                  $fieldOptions = $field->config['options'];
                  if ($fieldOptions === true) $fieldOptions = null;
                  $fieldOptions = $this->getOptionsFromModel($field, $fieldOptions);
                  return $fieldOptions;
              });
          }
  
          return $this->formWidgets[$field->fieldName] = $widget;
      }
code: protected function makeFormFieldWidget($field)
      {
          if ($field->type !== 'widget') {
              return null;
          }
  
          if (isset($this->formWidgets[$field->fieldName])) {
              return $this->formWidgets[$field->fieldName];
          }
  
          $widgetConfig = $this->makeConfig($field->config);
          $widgetConfig->alias = $this->alias . studly_case(HtmlHelper::nameToId($field->fieldName));
          $widgetConfig->sessionKey = $this->getSessionKey();
          $widgetConfig->previewMode = $this->previewMode;
          $widgetConfig->model = $this->model;
          $widgetConfig->data = $this->data;
          $widgetConfig->parentForm = $this;
  
          $widgetName = $widgetConfig->widget;
          $widgetClass = $this->widgetManager->resolveFormWidget($widgetName);
  
          if (!class_exists($widgetClass)) {
              throw new ApplicationException(Lang::get(
                  'backend::lang.widget.not_registered',
                  ['name' => $widgetClass]
              ));
          }
  
          $widget = $this->makeFormWidget($widgetClass, $field, $widgetConfig);
  
          /*
           * If options config is defined, request options from the model.
           */
          if (isset($field->config['options'])) {
              $field->options(function () use ($field) {
                  $fieldOptions = $field->config['options'];
                  if ($fieldOptions === true) $fieldOptions = null;
                  $fieldOptions = $this->getOptionsFromModel($field, $fieldOptions);
                  return $fieldOptions;
              });
          }
  
          return $this->formWidgets[$field->fieldName] = $widget;
      }
code_tokens: protected function makeFormFieldWidget ( $ field ) { if ( $ field -> type !== 'widget' ) { return null ; } if ( isset ( $ this -> formWidgets [ $ field -> fieldName ] ) ) { return $ this -> formWidgets [ $ field -> fieldName ] ; } $ widgetConfig = $ this -> makeConfig ( $ field -> config ) ; $ widgetConfig -> alias = $ this -> alias . studly_case ( HtmlHelper :: nameToId ( $ field -> fieldName ) ) ; $ widgetConfig -> sessionKey = $ this -> getSessionKey ( ) ; $ widgetConfig -> previewMode = $ this -> previewMode ; $ widgetConfig -> model = $ this -> model ; $ widgetConfig -> data = $ this -> data ; $ widgetConfig -> parentForm = $ this ; $ widgetName = $ widgetConfig -> widget ; $ widgetClass = $ this -> widgetManager -> resolveFormWidget ( $ widgetName ) ; if ( ! class_exists ( $ widgetClass ) ) { throw new ApplicationException ( Lang :: get ( 'backend::lang.widget.not_registered' , [ 'name' => $ widgetClass ] ) ) ; } $ widget = $ this -> makeFormWidget ( $ widgetClass , $ field , $ widgetConfig ) ; /*
           * If options config is defined, request options from the model.
           */ if ( isset ( $ field -> config [ 'options' ] ) ) { $ field -> options ( function ( ) use ( $ field ) { $ fieldOptions = $ field -> config [ 'options' ] ; if ( $ fieldOptions === true ) $ fieldOptions = null ; $ fieldOptions = $ this -> getOptionsFromModel ( $ field , $ fieldOptions ) ; return $ fieldOptions ; } ) ; } return $ this -> formWidgets [ $ field -> fieldName ] = $ widget ; }
docstring: Makes a widget object from a form field object.
  
  @param $field
  @return \Backend\Traits\FormWidgetBase|null
docstring_tokens: Makes a widget object from a form field object .