InputfieldWrapper::importArray() method

Import an array of Inputfield definitions to to this InputfieldWrapper instance

Your array should be an array of associative arrays, with each element describing an Inputfield. The following properties are required for each Inputfield definition:

  • type Which Inputfield module to use (may optionally exclude the "Inputfield" prefix).
  • name Name attribute to use for the Inputfield.
  • label Text label that appears above the Inputfield.

Example

// Example array for Inputfield definitions
array(
  array(
    'name' => 'fullname',
    'type' => 'text',
    'label' => 'Field label'
    'columnWidth' => 50,
    'required' => true,
  ),
  array(
    'name' => 'color',
    'type' => 'select',
    'label' => 'Your favorite color',
    'description' => 'Select your favorite color or leave blank if you do not have one.',
    'columnWidth' => 50,
    'options' => array(
       'red' => 'Brilliant Red',
       'orange' => 'Citrus Orange',
       'blue' => 'Sky Blue'
    )
  ),
  // alternative usage: associative array where name attribute is specified as key
  'my_fieldset' => array(
    'type' => 'fieldset',
    'label' => 'My Fieldset',
    'children' => array(
      'some_field' => array(
        'type' => 'text',
        'label' => 'Some Field',
      )
    )
);
// Note: you may alternatively use associative arrays where the keys are assumed to
// be the 'name' attribute.See the last item 'my_fieldset' above for an example. 

Usage

// basic usage
$inputfieldWrapper->importArray(array $a);

// usage with all arguments
$inputfieldWrapper->importArray(array $a, InputfieldWrapper $inputfields = null);

Arguments

NameType(s)Description
aarray

Array of Inputfield definitions

inputfields (optional)InputfieldWrapper

Specify the wrapper you want them added to, or omit to use current.

Return value

$this

Object instance it was called from (method supports fluent interface).


InputfieldWrapper methods and properties

API reference based on ProcessWire core version 3.0.236

Latest news

  • ProcessWire Weekly #523
    In the 523rd issue of ProcessWire Weekly we'll check out what's new in the core this week, share some new module related news, and more. Read on!
    Weekly.pw / 18 May 2024
  • ProFields Table Field with Actions support
    This week we have some updates for the ProFields table field (FieldtypeTable). These updates are primarily focused on adding new tools for the editor to facilitate input and management of content in a table field.
    Blog / 12 April 2024
  • Subscribe to weekly ProcessWire news

“The end client and designer love the ease at which they can update the website. Training beyond how to log in wasn’t even necessary since ProcessWire’s default interface is straightforward.” —Jonathan Lahijani