Jump to content

Module: ImportShorthand


hellomoto
 Share

Recommended Posts

Module programming is great. Maybe I am missing something but currently I cannot see the benefit of your module.

Example:
Field creation with built-in API

$f = new Field;
$f->name = 'field_label';
$f->type = 'FieldtypeWhatever';
$f->tags = 'tag1 tag2';
$f->label = 'Field Label';
$f->columnWidth = 50;
$f->save();

Field creation with your module

$IS = new ImportShorthand();
$IS->newField([[
  'name' => 'field_label',
  'type' => wire('modules')->get('FieldtypeWhatever'),
  'tags' => 'tag1 tag2',
  'label' => 'Field Label',
  'columnWidth' => 50,
  ],[
  // additional field options go here
]]);

 

Link to comment
Share on other sites

You can also do 

$f = new Field();
$f->setArray([
  'name' => 'field_label',
  'type' => wire('modules')->get('FieldtypeWhatever'),
  'tags' => 'tag1 tag2',
  'label' => 'Field Label',
  'columnWidth' => 50,
  ]
);

 

  • Like 4
Link to comment
Share on other sites

  • 2 years later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...