# Picea UI Welcome to the `picea-ui` documentation. This quick documentation will guide you through the use of the form system, every available UI elements and how to add customs one and individual components. Mostly everything you need to build and process form is available in this package. The first part is most input callable as a widget : ``` {% ui:text "fullname", "John Doe" %} ``` Current input support is : ```php - Input (string $source, array $attributes = [], array $options = []) - Checkbox (string $name, mixed $value = null, array $attributes = [], array $options = []) - Color (string $name, mixed $value = null, array $attributes = [], array $options = []) - Date (string $name, mixed $value = null, array $attributes = [], array $options = []) - Datetime (string $name, mixed $value = null, array $attributes = [], array $options = []) - Email (string $name, mixed $value = null, array $attributes = [], array $options = []) - File (string $name, mixed $value = null, array $attributes = [], array $options = []) - Hidden (string $name, mixed $value = null, array $attributes = [], array $options = []) - Image (string $source, array $attributes = [], array $options = []) - Numeric (string $name, mixed $value = null, array $attributes = [], array $options = []) - Password (string $name, mixed $value = null, array $attributes = [], array $options = []) - Radio (string $name, mixed $value = null, array $attributes = [], array $options = []) - Range (string $name, mixed $value = null, array $attributes = [], array $options = []) - Search (string $name, mixed $value = null, array $attributes = [], array $options = []) - Select (string $name, array $list, mixed $value = null, array $attributes = [], bool $strictComparison = true) - Tel (string $name, mixed $value = null, array $attributes = [], array $options = []) - Text (string $name, mixed $value = null, array $attributes = [], array $options = []) - Textarea (string $name, mixed $value = null, array $attributes = [], array $options = []) - Time (string $name, mixed $value = null, array $attributes = [], array $options = []) - Url (string $name, mixed $value = null, array $attributes = [], array $options = []) - Week (string $name, mixed $value = null, array $attributes = [], array $options = []) ``` **[PICEA]** So, using this code: ```html {% ui:form.post "user.save", current_url() %}
{% ui:text "fullname", $user->fullname, [ 'required' => 'required' ] %}
{% ui:text "email", $user->email %}
{% ui:select "role", [ 'user' => "User", 'moderator' => "Moderator", 'admin' => "Admin" ], $user->role, [ 'required' => 'required' ] %}
{% ui:endform %} ``` **[HTML]** Would render as such: ```html
``` ## Use your forms in controller Forms can be used to handle how your data is handled, from loading (get) to processing (post). The process is as simple as defining a Form, implementing FormInterface : ```php interface FormInterface { public function initialize(FormContextInterface $context) : void; public function validate(FormContextInterface $context) : bool; public function execute(FormContextInterface $context); } ``` `initialize` is called directly on `form()` method call. `validate` will be called if the request's method is either `post`, `put`, `patch` or `delete`, which implies **adding** / **editing** / **deleting**. `execute` will finally launch only if `validate` returns `true`. This is usually where you want to **save** / **destroy** your entities.