isArrayElement = $isArrayElement; $this->baseName = $baseName; $this->properties['form'] = $form; // calls setId() $form->registerElement( $this ); } /** * Sets the property $name to $value. * * @throws ezcBasePropertyNotFoundException if the property does not exist. * @param string $name * @param mixed $value * @ignore */ public function __set( $name, $value ) { switch ( $name ) { case 'form': case 'name': throw new ezcBasePropertyPermissionException( $name, ezcBasePropertyPermissionException::READ ); break; default: throw new ezcBasePropertyNotFoundException( $name ); break; } } /** * Returns the property $name. * * @throws ezcBasePropertyNotFoundException if the property does not exist. * @param string $name * @return mixed * @ignore */ public function __get( $name ) { switch ( $name ) { case 'form': case 'name': return isset( $this->properties[$name] ) ? $this->properties[$name] : null; break; default: throw new ezcBasePropertyNotFoundException( $name ); break; } } public function setId( $id ) { $this->properties['name'] = "{$this->baseName}_{$id}"; if( $this->isArrayElement == true ) { $this->properties['name'] .= "[]"; } } /** * Default event handler. Checks if the event is for this field. * If it is the event is accepted and dataRetrievedEvent() is called. * * TODO: add functionality for get */ public function handleEvent( ezcWgEvent $e ) { if( $e instanceof ezcWgFormEvent && isset( $_POST[$this->name] ) ) { $e->accept(); $this->dataRetrievedEvent( $e ); } } // called when data is retrieved for this form field. abstract public function dataRetrievedEvent( ezcWgFormEvent $e ); } ?>