Jump to content

Overriding a Field label via API


cosmicsafari
 Share

Recommended Posts

Hi all,

I am working on a module which creates templates, fields & pages upon install.

I have ran into an issue where I have a numerous fields which I would like to override their labels depending on the template they are used in.

Is it possible to do this dynamically via API at the point where I am creating the field group and template using the API.

The following is the code which I am using at the moment.

foreach($templatesArray as $name => $cTemplate)
{
  if(array_key_exists('fieldGroup',$cTemplate)) {
    $fg = new Fieldgroup();
    $fg->name = $name . '-fg';
    foreach ($cTemplate['fieldGroup'] as $field) {
	//possibly at this point?
	$fg->add($this->fields->get($field));
    }
    $fg->save();
  }

  $t = new Template();
  $t->name = $name;
  $t->fieldgroup = $fg;
  $t->noChildren = 1;
  $t->setIcon($cTemplate['icon']);
  $t->save();
}

Is this even possible?

Link to comment
Share on other sites

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...