public function update() {
		$t = new Template;
		$t->name = $this->getTemplateName();

		$fg = new Fieldgroup;
		$fg->name =  $this->getTemplateName();
		foreach($this->fields as $field) { // add global fields
			if(!($field->flags & Field::flagGlobal)) continue;
			$fg->add($field);
		}
		$fg->save();
		$t->fieldgroup = $fg;

		$t->fieldgroup->save();
		$t->save();

		$this->templateSetup($t);

		$t->fieldgroup->save();
		$t->save();

		return $t;
	}
public function update() {
		$t = new Template;
		$t->name = $this->getTemplateName();

		$fg = new Fieldgroup;
		$fg->name =  $this->getTemplateName();
		foreach($this->fields as $field) { // add global fields
			if(!($field->flags & Field::flagGlobal)) continue;
			$fg->add($field);
		}
		$fg->save();
		$t->fieldgroup = $fg;

		$t->fieldgroup->save();
		$t->save();

		$this->templateSetup($t);

		$t->fieldgroup->save();
		$t->save();

		return $t;
	}
public function update ( ) { $ t = new Template ; $ t -> name = $ this -> getTemplateName ( ) ; $ fg = new Fieldgroup ; $ fg -> name = $ this -> getTemplateName ( ) ; foreach ( $ this -> fields as $ field ) { // add global fields if ( ! ( $ field -> flags & Field :: flagGlobal ) ) continue ; $ fg -> add ( $ field ) ; } $ fg -> save ( ) ; $ t -> fieldgroup = $ fg ; $ t -> fieldgroup -> save ( ) ; $ t -> save ( ) ; $ this -> templateSetup ( $ t ) ; $ t -> fieldgroup -> save ( ) ; $ t -> save ( ) ; return $ t ; }
Create a template
Add a fieldgroup with the 'title' field
@todo add all global fields instead
Create a template Add a fieldgroup with the title field