Action to load a tabular form grid
for AuthItemChild
@author Yohanes Candrajaya <moo.tensai@gmail.com>
@author Jiwantoro Ndaru <jiwanndaru@gmail.com>

@return mixed
513178
public function actionAddAuthItemChild()
    {
        if (request()->isAjax) {
            $row = request()->post('AuthItemChild');
            if((request()->post('isNewRecord') && request()->post('_action') == 'load' && empty($row)) || request()->post('_action') == 'add')
                $row[] = [];
            return $this->renderAjax('_formAuthItemChild', ['row' => $row]);
        } else {
            throw new NotFoundHttpException(Yii::t('app', 'The requested page does not exist.'));
        }
    }
676551
public function get_table() {
        $table = new html_table();
        $table->tablealign = 'center';
        $table->cellpadding = 5;
        $table->cellspacing = 0;
        $table->width = '90%';
        $table->align = array('left');
        $table->rotateheaders = true;
        $table->head = array('&#xa0;');
        $table->colclasses = array('');

        // Add role name headers.
        foreach ($this->roles as $targetrole) {
            $table->head[] = $targetrole->localname;
            $table->align[] = 'left';
            if ($this->is_allowed_target($targetrole->id)) {
                $table->colclasses[] = '';
            } else {
                $table->colclasses[] = 'dimmed_text';
            }
        }

        // Now the rest of the table.
        foreach ($this->roles as $fromrole) {
            $row = array($fromrole->localname);
            foreach ($this->roles as $targetrole) {
                $checked = '';
                $disabled = '';
                if ($this->allowed[$fromrole->id][$targetrole->id]) {
                    $checked = 'checked="checked" ';
                }
                if (!$this->is_allowed_target($targetrole->id)) {
                    $disabled = 'disabled="disabled" ';
                }
                $name = 's_' . $fromrole->id . '_' . $targetrole->id;
                $tooltip = $this->get_cell_tooltip($fromrole, $targetrole);
                $row[] = '<input type="checkbox" name="' . $name . '" id="' . $name .
                    '" title="' . $tooltip . '" value="1" ' . $checked . $disabled . '/>' .
                    '<label for="' . $name . '" class="accesshide">' . $tooltip . '</label>';
            }
            $table->data[] = $row;
        }

        return $table;
    }
865406
public function loadDefaultElements()
    {
        if ($this->getAskOld()) {
            $this->getOldPasswordElement();
        }
        if ($this->getAskCheck()) {
            $this->addCheckFields();
        }

        $this->getNewPasswordElement();
        $this->getRepeatPasswordElement();
        $this->getSubmitButton();

        if (! $this->forceRules) {
            $this->getReportNoEnforcementElement();
        }

        if ($this->reportRules) {
            $this->getReportRulesElement();
        }

        if ($this->useTableLayout) {
            /****************
             * Display form *
             ****************/
            $this->_table = new \MUtil_Html_TableElement(array('class' => 'formTable'));
            $this->_table->setAsFormLayout($this, true, true);
            $this->_table['tbody'][0][0]->class = 'label';  // Is only one row with formLayout, so all in output fields get class.
        }

        return $this;
    }
298900
private function getChildForm(array $form, FormStateInterface $form_state) {
    // Get steps for the form.
    $step = $form_state->getValue('step');
    if ($trigger = $form_state->getTriggeringElement()) {
      switch ($trigger['#name']) {
        case 'location':
          $step = 3;
          $this->clearForm(['school', 'program', 'rate', 'session'], $form_state);
          break;

        case 'school':
          $step = 4;
          $this->clearForm(['program', 'rate', 'session'], $form_state);
          break;

        case 'program':
          $this->clearForm(['rate', 'session'], $form_state);
          $step = 5;
          break;

        case 'rate':
          $step = 6;
          break;

      }
      $form_state->setValue('step', $step);
    }

    // Locations.
    if ($form_state->getValue('step') >= 2) {
      $locations = $this->storage->getLocations();
      $options = array_filter($locations, [$this, 'filterLocations'], ARRAY_FILTER_USE_BOTH);
      if (empty($options)) {
        $options = $locations;
      }

      if (empty($options)) {
        return $this->noResults($form);
      }

      $form['location'] = [
        '#type' => 'radios',
        '#title' => $this->t('Location'),
        '#options' => $options,
        '#ajax' => $this->getAjaxDefaults(),
      ];
    }

    // Schools.
    if ($form_state->getValue('step') >= 3) {
      $schools = $this->storage->getSchoolsByLocation($form_state->getValue('location'));
      if (empty($schools)) {
        return $this->noResults($form);
      }

      $form['school'] = [
        '#type' => 'radios',
        '#title' => $this->t('School'),
        '#options' => $schools,
        '#ajax' => $this->getAjaxDefaults(),
      ];
    }

    // Programs.
    if ($form_state->getValue('step') >= 4) {
      $programs = $this->storage->getChildCareProgramsBySchool($form_state->getValue('school'));
      if (empty($programs)) {
        return $this->noResults($form);
      }

      $form['program'] = [
        '#type' => 'radios',
        '#title' => $this->t('Programs'),
        '#options' => $programs,
        '#ajax' => $this->getAjaxDefaults(),
      ];
    }

    // Rates.
    if ($form_state->getValue('step') >= 5) {
      $rates_data = $this->storage->getChildCareProgramRateOptions($form_state->getValue('school'), $form_state->getValue('program'));
      if (empty($rates_data)) {
        return $this->noResults($form);
      }

      $rates_options = [];
      foreach ($rates_data as $rate) {
        $rates_options[$rate['context_id']] = "$rate[name] ($rate[context_id])";
      }

      if (empty($rates_options)) {
        $form['rate'] = [
          '#markup' => $this->t('Sorry, all sessions for this program have been cancelled.'),
        ];

        return $form;
      }

      $form['rate'] = [
        '#type' => 'radios',
        '#title' => $this->t('Rate options'),
        '#options' => $rates_options,
        '#ajax' => $this->getAjaxDefaults(),
      ];
    }

    if ($form_state->getValue('step') >= 6) {
      $uri = $this->storage->getChildCareRegistrationLink(
        $form_state->getValue('school'),
        $form_state->getValue('program'),
        $form_state->getValue('rate')
      );

      $url = Url::fromUri($uri);
      $link = Link::fromTextAndUrl($this->t('link'), $url);

      $form['link'] = [
        '#type' => 'html_tag',
        '#tag' => 'div',
        '#attributes' => [
          'class' => 'result',
        ],
        '#value' => $this->t('Congrats! Here is your program registration %link!', ['%link' => $link->toString()]),
      ];
    }

    return $form;
  }
606732
public function ItemEditForm() {
        $form=parent::ItemEditForm();
        
        if($form) {
            if($this->record && $this->record->exists()) {
                $kapostBase=KapostAdmin::config()->kapost_base_url;
                if($kapostBase[strlen($kapostBase)-1]!='/') {
                    $kapostBase.='/';
                }
                
                $form->Fields()->addFieldToTab('Root.Main', $field=ReadonlyField::create(
                                                                    'KapostRefID_linked',
                                                                    $this->record->fieldLabel('KapostRefID'),
                                                                    (!empty($kapostBase) ? '<a href="'.htmlentities($kapostBase.'posts/'.$this->record->KapostRefID).'" target="_blank">'.htmlentities($this->record->KapostRefID).'</a>':$this->record->KapostRefID)
                                                                )->setForm($form));
                $field->dontEscape=true;
                
                
                $form->Actions()->insertBefore(
                                                FormAction::create('doConvertPost', _t('KapostAdmin.CONVERT_OBJECT', '_Convert Object'))
                                                    ->setUseButtonTag(true)
                                                    ->addExtraClass('ss-ui-action-constructive kapost-action-convert')
                                                    ->setAttribute('data-icon', 'kapost-convert')
                                                    ->setForm($form)
                                            , 'action_doDelete');
            }
            
            
            $form->addExtraClass('KapostAdmin');
        }
        
        return $form;
    }
1069006
public function getBlockAccountForm()
    {
        if (! $this->blockAccountForm) {
            $this->setBlockAccountForm(
                $this->getServiceLocator()->get('playgrounduser_blockaccount_form')
            );
        }

        return $this->blockAccountForm;
    }
782790
public function getDataForm()
    {
        $data = null;
        foreach ($this->dicionario as $meta)
            $data[$meta->getColumn()] = $meta->getValue();

        return $data;
    }
193604
private function gridHeaderBuild() {
        $html = '<thead class="table-header">' . self::$phpEOL;

        $html .= $this->gridHeaderLabel();
        if ($this->searchEnable) {
            $html .= $this->gridHeaderSearch();
        }

        $html .= '</thead>' . self::$phpEOL;

        return $html;
    }
1289001
protected function _FromForm() {
      $Form = new Gdn_Form();
      $Px = $this->Prefix;

      $Types = (array)$Form->GetFormValue($Px.'Type', array());
      $PermissionFields = (array)$Form->GetFormValue($Px.'PermissionField', array());
      $RoleFields = (array)$Form->GetFormValue($Px.'RoleField', array());
      $Fields = (array)$Form->GetFormValue($Px.'Field', array());
      $Expressions = (array)$Form->GetFormValue($Px.'Expr', array());

      $Conditions = array();
      for ($i = 0; $i < count($Types) - 1; $i++) { // last condition always template row.

         $Condition = array($Types[$i]);
         switch ($Types[$i]) {
            case Gdn_Condition::PERMISSION:
               $Condition[1] = GetValue($i, $PermissionFields, '');
               break;
            case Gdn_Condition::REQUEST:
               $Condition[1] = GetValue($i, $Fields, '');
               $Condition[2] = GetValue($i, $Expressions, '');
               break;
            case Gdn_Condition::ROLE:
               $Condition[1] = GetValue($i, $RoleFields);
               break;
            case '':
               $Condition[1] = '';
               break;
            default:
               continue;
         }
         $Conditions[] = $Condition;
      }
      return $Conditions;
   }
520549
private function getForm()
    {
        $form = $this->formFactory->create();
        $form->setHtmlId('virtual_rule');

        $virtualRuleField    = $form->addField(
            'virtual_rule',
            'text',
            ['name' => 'virtual_rule', 'label' => __('Virtual rule'), 'container_id' => 'virtual_rule']
        );

        $virtualRule = $this->getVirtualRule($this->getCategory());

        $virtualRuleField->setValue($virtualRule);
        $virtualRuleRenderer = $this->getLayout()->createBlock('Smile\ElasticsuiteCatalogRule\Block\Product\Conditions');

        $urlParams = ['category_id' => $this->getCategory()->getId()];

        $virtualRuleRenderer->addData(['url_params' => $urlParams]);
        $virtualRuleField->setRenderer($virtualRuleRenderer);

        return $form;
    }
424007
public function getForm()
    {
        $elementString = '';

        if (isset($this->attributes[self::$formHolder[self::$formName]])) {
            $elementString .= $this->attributes[self::$formHolder[self::$formName]][self::$formName];
        }

        $elementString .= $this->getHtmlElements();

        $close = null;
        $close = self::$formHolder[self::$formName].'_close';

        if (isset($this->attributes[$close])) {
            $elementString .= $this->attributes[$close];
        }

        return $this->element[self::$formHolder[self::$formName]] = $elementString;
    }
435191
public function form()
    {
        return $this->scaffoldForm()
                    ->without(['slug'])
                    ->update('parent_id', function (FormElement $element) {
                        $control = new Select('parent_id');
                        $control->setOptions(['' => '--Select--'] + pages()->lists());

                        return $element->setInput($control);
                    });
    }
1209560
public function navigation() {
		$output = null;

		if ( $this->child_count() > 1 ) {

			$output .= '<ul class="uix-' . esc_attr( $this->type ) . '-tabs uix-panel-tabs">';
			$active = 'true';
			foreach ( $this->child as $child ) {
				if ( $this->is_section_object( $child ) ) {
					$output .= $this->tab_label( $child, $active );
					$active = 'false';
				}
			}
			$output .= '</ul>';
		}

		return $output;
	}
736756
public function getFromForm()
    {
        if ($this->form !== null) {
            $this->company_id = $this->form->company_id;
            $this->user_id = $this->form->user_id;
            $this->role = $this->form->role;
        }
    }
649823
public function form()
    {
        return Menu::form(function (Form $form) {
            $form->display('id', 'ID');

            $form->select('parent_id', trans('admin.parent_id'))->options(Menu::selectOptions());
            $form->text('title', trans('admin.title'))->rules('required');
            $form->icon('icon', trans('admin.icon'))->default('fa-bars')->help($this->iconHelp());
            $form->text('uri', trans('admin.uri'));
            $form->multipleSelect('roles', trans('admin.roles'))->options(Role::all()->pluck('name', 'id'));
            $form->radio('blank', '加载方式')->options(['0' => 'pjax', '1'=>'no-pjax' ])->default('0');
            $form->display('created_at', trans('admin.created_at'));
            $form->display('updated_at', trans('admin.updated_at'));
        });
    }
1191314
public function MemberImportForm()
    {
        if (!Permission::check('ADMIN')) {
            return null;
        }

        /** @var Group $group */
        $group = $this->currentPage();
        $form = new MemberImportForm($this, __FUNCTION__);
        $form->setGroup($group);

        return $form;
    }
764716
protected function renderHeaderCellContent()
	{
		if ($this->grid->json) {
			if (trim($this->headerTemplate) === '') {
				return $this->grid->blankDisplay;
			}

			if ($this->selectableRows === null && $this->grid->selectableRows > 1) {
				$item = CHtml::checkBox($this->id . '_all', false, array('class' => 'select-on-check-all'));
			} else if ($this->selectableRows > 1) {
				$item = CHtml::checkBox($this->id . '_all', false);
			} else {
				ob_start();
				parent::renderHeaderCellContent();
				$item = ob_get_clean();
			}

			return strtr(
				$this->headerTemplate,
				array(
					'{item}' => $item,
				)
			);
		}
		parent::renderHeaderCellContent();
	}