Add form fields defined in theme.yaml
438210
public function formExtendFields($form)
    {
        $model = $form->model;
        $theme = $this->findThemeObject($model->theme);
        $config = $theme->getFormConfig();

        if ($fields = array_get($config, 'fields')) {
            $form->addFields($fields);
        }

        if ($fields = array_get($config, 'tabs.fields')) {
            $form->addTabFields($fields);
        }

        if ($fields = array_get($config, 'secondaryTabs.fields')) {
            $form->addSecondaryTabFields($fields);
        }
    }
785948
def format_config_for_editing(data):
    """"""
    return yaml.safe_dump(data, default_flow_style=False, encoding=None, allow_unicode=True)
414425
function addForm(schema, form, cloneFormsDeprecated) {
      var isAdmin = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
      var indicators = arguments.length > 4 ? arguments[4] : undefined;
      var conditionsExprCompiler, contents, deploymentValues, jsonql, metadata, reverseJoins;
      contents = [];
      metadata = []; // Get deployments

      deploymentValues = _.map(form.deployments, function (dep) {
        return {
          id: dep._id,
          name: {
            en: dep.name
          }
        };
      });
      metadata.push({
        id: "deployment",
        type: "enum",
        name: {
          en: "Deployment"
        },
        enumValues: deploymentValues
      }); // Add user

      metadata.push({
        id: "user",
        name: {
          en: "Enumerator"
        },
        type: "join",
        join: {
          type: "n-1",
          toTable: "users",
          fromColumn: "user",
          toColumn: "_id"
        }
      }); // Add status

      metadata.push({
        id: "status",
        type: "enum",
        name: {
          en: "Status"
        },
        enumValues: [{
          id: "draft",
          name: {
            en: "Draft"
          }
        }, {
          id: "pending",
          name: {
            en: "Pending"
          }
        }, {
          id: "final",
          name: {
            en: "Final"
          }
        }, {
          id: "rejected",
          name: {
            en: "Rejected"
          }
        }]
      }); // Add code

      metadata.push({
        id: "code",
        type: "text",
        name: {
          en: "Response Code"
        }
      }); // Add startedOn

      metadata.push({
        id: "startedOn",
        type: "datetime",
        name: {
          en: "Drafted On"
        }
      }); // Add submitted on

      metadata.push({
        id: "submittedOn",
        type: "datetime",
        name: {
          en: "Submitted On"
        }
      }); // Add approvalLevel. Only has value if pending

      jsonql = {
        type: "case",
        cases: [{
          when: {
            type: "op",
            op: "=",
            exprs: [{
              type: "field",
              tableAlias: "{alias}",
              column: "status"
            }, {
              type: "literal",
              value: "pending"
            }]
          },
          then: {
            type: "op",
            op: "::text",
            exprs: [{
              type: "op",
              op: "jsonb_array_length",
              exprs: [{
                type: "field",
                tableAlias: "{alias}",
                column: "approvals"
              }]
            }]
          }
        }]
      };
      metadata.push({
        id: "approvalLevel",
        type: "enum",
        name: {
          en: "Approval Level"
        },
        jsonql: jsonql,
        enumValues: [{
          id: "0",
          name: {
            en: "Pending Level 1"
          }
        }, {
          id: "1",
          name: {
            en: "Pending Level 2"
          }
        }, {
          id: "2",
          name: {
            en: "Pending Level 3"
          }
        }, {
          id: "3",
          name: {
            en: "Pending Level 4"
          }
        }]
      }); // Add IpAddress

      metadata.push({
        id: "ipAddress",
        type: "text",
        name: {
          en: "IP Address"
        }
      });
      contents.push({
        id: "metadata",
        type: "section",
        name: {
          en: "Response Metadata"
        },
        desc: {
          en: "Information about the response such as status, date, and IP Address"
        },
        contents: metadata
      });
      conditionsExprCompiler = new ConditionsExprCompiler(form.design); // List of joins in format: { table: destination table, column: join column to add }

      reverseJoins = [];
      this.addFormItem(form.design, contents, "responses:".concat(form._id), conditionsExprCompiler, null, reverseJoins); // Add to schema

      schema = schema.addTable({
        id: "responses:".concat(form._id),
        name: form.design.name,
        primaryKey: "_id",
        contents: contents,
        ordering: "submittedOn",
        label: "code"
      }); // Add any roster tables

      schema = this.addRosterTables(schema, form.design, conditionsExprCompiler, reverseJoins, "responses:".concat(form._id)); // Add reverse joins from entity and site questions

      schema = this.addReverseJoins(schema, form, reverseJoins);

      if (isAdmin) {
        schema = this.addConfidentialData(schema, form, conditionsExprCompiler);
        schema = this.addConfidentialDataForRosters(schema, form, conditionsExprCompiler);
      }

      schema = this.addCalculations(schema, form);
      schema = this.addIndicatorCalculations(schema, form, indicators, false); // Create table

      return schema;
    }
418647
function field_init( $args ) {
		if ( ! isset( $args['css_vars'] ) ) {
			return;
		}
		$args['css_vars'] = (array) $args['css_vars'];
		if ( isset( $args['css_vars'][0] ) && is_string( $args['css_vars'][0] ) ) {
			$args['css_vars'] = [ $args['css_vars'] ];
		}
		foreach ( $args['css_vars'] as $key => $val ) {
			if ( ! isset( $val[1] ) ) {
				$args['css_vars'][ $key ][1] = '$';
			}
		}
		$this->fields[ $args['settings'] ] = $args;
	}
1373623
function() {
    this.appendDummyInput()
        .appendField(new Blockly.FieldIconMenu(
            [
              {src: Blockly.mainWorkspace.options.pathToMedia + 'icons/set-led_mystery.svg',
                value: 'mystery', width: 48, height: 48, alt: 'Mystery'},
              {src: Blockly.mainWorkspace.options.pathToMedia + 'icons/set-led_yellow.svg',
                value: 'yellow', width: 48, height: 48, alt: 'Yellow'},
              {src: Blockly.mainWorkspace.options.pathToMedia + 'icons/set-led_orange.svg',
                value: 'orange', width: 48, height: 48, alt: 'Orange'},
              {src: Blockly.mainWorkspace.options.pathToMedia + 'icons/set-led_coral.svg',
                value: 'coral', width: 48, height: 48, alt: 'Coral'},
              {src: Blockly.mainWorkspace.options.pathToMedia + 'icons/set-led_magenta.svg',
                value: 'magenta', width: 48, height: 48, alt: 'Magenta'},
              {src: Blockly.mainWorkspace.options.pathToMedia + 'icons/set-led_purple.svg',
                value: 'purple', width: 48, height: 48, alt: 'Purple'},
              {src: Blockly.mainWorkspace.options.pathToMedia + 'icons/set-led_blue.svg',
                value: 'blue', width: 48, height: 48, alt: 'Blue'},
              {src: Blockly.mainWorkspace.options.pathToMedia + 'icons/set-led_green.svg',
                value: 'green', width: 48, height: 48, alt: 'Green'},
              {src: Blockly.mainWorkspace.options.pathToMedia + 'icons/set-led_white.svg',
                value: 'white', width: 48, height: 48, alt: 'White'}
            ]), 'CHOICE');
    this.setOutput(true);
    this.setColour(Blockly.Colours.looks.primary,
        Blockly.Colours.looks.secondary,
        Blockly.Colours.looks.tertiary
    );
  }
881465
public function sectionStdEdit()
	{
		$templates = Templates::getInstance();
		$item = $templates->get(arg('id'), 'std', true);
		$form = array(
			'name' => 'editForm',
			'caption' => Eresus_Kernel::app()->getPage()->title . ADM_T_DIV . ADM_EDIT,
			'width' => '100%',
			'fields' => array (
				array('type'=>'hidden','name'=>'action', 'value'=>'update'),
				array('type'=>'hidden','name'=>'section', 'value'=>arg('section')),
				array('type'=>'hidden','name'=>'name'),
				array('type'=>'edit','name'=>'_name','label' => ADM_THEMES_FILENAME_LABEL,
					'width' => '200px', 'comment' => '.tmpl (' .
					$this->stdTemplates[$item['name']]['caption'].')',
					'disabled' => true, 'value'=>$item['name']),
				array('type'=>'text','name'=>'hint', 'value' =>
					isset($this->stdTemplates[$item['name']]['hint']) ?
						$this->stdTemplates[$item['name']]['hint']:'', 'extra' => 'id="templateHint"'),
				array('type'=>'memo','name'=>'code', 'height'=>'30', 'syntax' => 'html'),
			),
			'buttons' => array('ok', 'apply', 'cancel'),
		);
		/** @var TAdminUI $page */
		$page = Eresus_Kernel::app()->getPage();
		$result = $page->renderForm($form, $item);
		return $result;
	}
704199
def formfield(self, **kwargs):
        """"""
        defaults = {
            'form_class': LocalizedIntegerFieldForm
        }

        defaults.update(kwargs)
        return super().formfield(**defaults)
419946
def attachedimage_form_factory(lang='en', debug=False):
    ''' 
    '''
    yui = '' if debug else '.yui'
    class _AttachedImageAdminForm(forms.ModelForm):

        caption = forms.CharField(label=_('Caption'), required=False)

        class Media:
            js = [
                  'generic_images/js/mootools-1.2.4-core-yc.js',
                  'generic_images/js/GearsUploader.%s%s.js' % (lang, yui,),
                  'generic_images/js/AttachedImageInline.js',
            ]

        class Meta:
            model = AttachedImage
    return _AttachedImageAdminForm
990076
def formfield(self, **kwargs):
        """"""
        defaults = {
            'form_class': LocalizedCharFieldForm
        }

        defaults.update(kwargs)
        return super().formfield(**defaults)
795784
public function getFormFields()
    {
        if (!$theme = CmsTheme::load($this->theme)) {
            throw new Exception(Lang::get('Unable to find theme with name :name', $this->theme));
        }

        $config = $theme->getFormConfig();

        return array_get($config, 'fields', []) +
            array_get($config, 'tabs.fields', []) +
            array_get($config, 'secondaryTabs.fields', []);
    }
122899
public function init()
    {
        // Works only on backend site
        if (!OL_ZEUS_ISADMIN) {
            return;
        }

        // Check filepath
        if (empty($this->filepath)) {
            return;
        }

        // Get configurations
        $configs = include $this->filepath;

        // Check
        if (empty($configs)) {
            return;
        }

        // Iterate on configs
        foreach ($configs as $key => $props) {
            $props = !is_array($props) ? [$props] : $props;

            // Add admin theme
            $this->addAdminTheme($key, $props);
        }
    }
1321377
protected function defineFormFields()
    {
        if ($this->fieldsDefined) {
            return;
        }

        /**
         * @event backend.form.extendFieldsBefore
         * Called before the form fields are defined
         *
         * Example usage:
         *
         *     Event::listen('backend.form.extendFieldsBefore', function((\Backend\Widgets\Form) $formWidget) {
         *         // You should always check to see if you're extending correct model/controller
         *         if (!$widget->model instanceof \Foo\Example\Models\Bar) {
         *             return;
         *         }
         *
         *         // Here you can't use addFields() because it will throw you an exception because form is not yet created
         *         // and it does not have tabs and fields
         *         // For this example we will pretend that we want to add a new field named example_field
         *         $widget->fields['example_field'] = [
         *             'label' => 'Example field',
         *             'comment' => 'Your example field',
         *             'type' => 'text',
         *         ];
         *     });
         *
         * Or
         *
         *     $formWidget->bindEvent('form.extendFieldsBefore', function () use ((\Backend\Widgets\Form $formWidget)) {
         *         // You should always check to see if you're extending correct model/controller
         *         if (!$widget->model instanceof \Foo\Example\Models\Bar) {
         *             return;
         *         }
         *
         *         // Here you can't use addFields() because it will throw you an exception because form is not yet created
         *         // and it does not have tabs and fields
         *         // For this example we will pretend that we want to add a new field named example_field
         *         $widget->fields['example_field'] = [
         *             'label' => 'Example field',
         *             'comment' => 'Your example field',
         *             'type' => 'text',
         *         ];
         *     });
         *
         */
        $this->fireSystemEvent('backend.form.extendFieldsBefore');

        /*
         * Outside fields
         */
        if (!isset($this->fields) || !is_array($this->fields)) {
            $this->fields = [];
        }

        $this->allTabs->outside = new FormTabs(FormTabs::SECTION_OUTSIDE, (array) $this->config);
        $this->addFields($this->fields);

        /*
         * Primary Tabs + Fields
         */
        if (!isset($this->tabs['fields']) || !is_array($this->tabs['fields'])) {
            $this->tabs['fields'] = [];
        }

        $this->allTabs->primary = new FormTabs(FormTabs::SECTION_PRIMARY, $this->tabs);
        $this->addFields($this->tabs['fields'], FormTabs::SECTION_PRIMARY);

        /*
         * Secondary Tabs + Fields
         */
        if (!isset($this->secondaryTabs['fields']) || !is_array($this->secondaryTabs['fields'])) {
            $this->secondaryTabs['fields'] = [];
        }

        $this->allTabs->secondary = new FormTabs(FormTabs::SECTION_SECONDARY, $this->secondaryTabs);
        $this->addFields($this->secondaryTabs['fields'], FormTabs::SECTION_SECONDARY);

        /**
         * @event backend.form.extendFields
         * Called after the form fields are defined
         *
         * Example usage:
         *
         *     Event::listen('backend.form.extendFields', function((\Backend\Widgets\Form) $formWidget) {
         *         // Only for the User controller
         *         if (!$widget->getController() instanceof \RainLab\User\Controllers\Users) {
         *             return;
         *         }
         *
         *         // Only for the User model
         *         if (!$widget->model instanceof \RainLab\User\Models\User) {
         *             return;
         *         }
         *
         *         // Add an extra birthday field
         *         $widget->addFields([
         *             'birthday' => [
         *                 'label'   => 'Birthday',
         *                 'comment' => 'Select the users birthday',
         *                 'type'    => 'datepicker'
         *             ]
         *         ]);
         *
         *         // Remove a Surname field
         *         $widget->removeField('surname');
         *     });
         *
         * Or
         *
         *     $formWidget->bindEvent('form.extendFields', function () use ((\Backend\Widgets\Form $formWidget)) {
         *         // Only for the User controller
         *         if (!$widget->getController() instanceof \RainLab\User\Controllers\Users) {
         *             return;
         *         }
         *
         *         // Only for the User model
         *         if (!$widget->model instanceof \RainLab\User\Models\User) {
         *             return;
         *         }
         *
         *         // Add an extra birthday field
         *         $widget->addFields([
         *             'birthday' => [
         *                 'label'   => 'Birthday',
         *                 'comment' => 'Select the users birthday',
         *                 'type'    => 'datepicker'
         *             ]
         *         ]);
         *
         *         // Remove a Surname field
         *         $widget->removeField('surname');
         *     });
         *
         */
        $this->fireSystemEvent('backend.form.extendFields', [$this->allFields]);

        /*
         * Convert automatic spanned fields
         */
        foreach ($this->allTabs->outside->getFields() as $fields) {
            $this->processAutoSpan($fields);
        }

        foreach ($this->allTabs->primary->getFields() as $fields) {
            $this->processAutoSpan($fields);
        }

        foreach ($this->allTabs->secondary->getFields() as $fields) {
            $this->processAutoSpan($fields);
        }

        /*
         * At least one tab section should stretch
         */
        if (
            $this->allTabs->secondary->stretch === null
            && $this->allTabs->primary->stretch === null
            && $this->allTabs->outside->stretch === null
        ) {
            if ($this->allTabs->secondary->hasFields()) {
                $this->allTabs->secondary->stretch = true;
            }
            elseif ($this->allTabs->primary->hasFields()) {
                $this->allTabs->primary->stretch = true;
            }
            else {
                $this->allTabs->outside->stretch = true;
            }
        }

        /*
         * Bind all form widgets to controller
         */
        foreach ($this->allFields as $field) {
            if ($field->type !== 'widget') {
                continue;
            }

            $widget = $this->makeFormFieldWidget($field);
            $widget->bindToController();
        }

        $this->fieldsDefined = true;
    }
586319
function addOptions() {
		if ( is_array( $this->options ) )
			extract( $this->options, EXTR_SKIP );

		global $themecolors;

		if ( empty($bg) )
			$bg = isset( $themecolors['bg'] ) ? $themecolors['bg'] : 'transparent';
		if ( empty($fg) )
			$fg = isset( $themecolors['text'] ) ? $themecolors['text'] : '000000';

		if ( empty( $method ) )
			$method = 'Automattic_Latex_WPCOM';

		if ( empty( $css ) )
			$css = 'img.latex { vertical-align: middle; border: none; background: none; }';

		if ( empty( $wrapper ) )
			$wrapper = false;

		$this->options = compact( 'bg', 'fg', 'method', 'css', 'wrapper' );
		update_option( 'pb_latex', $this->options );
	}
1252416
def apply_widget_options(self, field_name):
        
        widget = self.fields[field_name].widget

        if isinstance(widget, forms.DateInput):
            widget.input_type = 'date'

        if isinstance(widget, forms.TimeInput):
            widget.input_type = 'time'

        if isinstance(widget, forms.SplitDateTimeWidget):
            widget.widgets[0].input_type = 'date'
            widget.widgets[1].input_type = 'time'
983649
def formfield(self, **kwargs):
        
        from yacms.generic.forms import KeywordsWidget
        kwargs["widget"] = KeywordsWidget
        return super(KeywordsField, self).formfield(**kwargs)
565929
function form () {
  form.form = $("#swagger-parser-form");

  form.allow = {
    label: form.form.find("#allow-label"),
    menu: form.form.find("#allow-menu"),
    json: form.form.find("input[name=allow-json]"),
    yaml: form.form.find("input[name=allow-yaml]"),
    text: form.form.find("input[name=allow-text]"),
    empty: form.form.find("input[name=allow-empty]"),
    unknown: form.form.find("input[name=allow-unknown]")
  };

  form.refs = {
    label: form.form.find("#refs-label"),
    menu: form.form.find("#refs-menu"),
    external: form.form.find("input[name=refs-external]"),
    circular: form.form.find("input[name=refs-circular]")
  };

  form.validate = {
    label: form.form.find("#validate-label"),
    menu: form.form.find("#validate-menu"),
    schema: form.form.find("input[name=validate-schema]"),
    spec: form.form.find("input[name=validate-spec]")
  };

  form.tabs = {
    url: form.form.find("#url-tab"),
    text: form.form.find("#text-tab")
  };

  form.method = {
    button: form.form.find("button[name=method]"),
    menu: form.form.find("#method-menu")
  };

  form.samples = {
    url: {
      container: form.form.find("#url-sample"),
      link: form.form.find("#url-sample-link"),
    },
    text: {
      container: form.form.find("#text-sample"),
      link: form.form.find("#text-sample-link"),
    }
  };

  form.url = form.form.find("input[name=url]");
  form.textBox = null; // This is set in editors.js
  form.bookmark = form.form.find("#bookmark");
}
1086974
protected function wizardAddField()
    {
        // Required
        $this->validatePrompt('title', $this->text('Name'), 'field');
        $this->validateMenu('type', $this->text('Type'), 'field', $this->field->getTypes());
        $this->validateMenu('widget', $this->text('Widget'), 'field', $this->field->getWidgetTypes());

        // Optional
        $this->validatePrompt('status', $this->text('Status'), 'field', 0);
        $this->validatePrompt('weight', $this->text('Weight'), 'field', 0);

        $this->validateComponent('field');
        $this->addField();
    }