Renderable
Creating your own renderable
Sometimes you need to customize the rendered output as well, to implement specific widgets, add new attributes to the HTML etc. Renderables work by composition, so often you may just write the classe for the HTML frontend. You can use a script to generate the class stub for you.
bash vendor/corollarium/formularium/util/makeFramework.sh [yourfrontend] Datatype_xxx.php
This will generate a Frontend/[yourfrontend]/Renderable/Renderable_xxx.php file.
You often will want to use an existing basetype to inherit and just alter the HTML. Remember that you may receive HTML from previous frameworks and other ones might use it later when implementing your code.
Remember to register your namespace in your application so they can be autoloaded:
RenderableFactory::appendNamespace('MyApp\\Renderable');
Parameters
These are basic parameters often supported for renderables:
-
Renderable::COMMENT => stringA comment to be printed explaining the field. -
Renderable::DEFAULTVALUE => mixedA default value -
Renderable::DISABLED => booleanRender, but make it disabled -
Renderable::HIDDEN => booleanRender, but make it hidden -
Renderable::ICON => stringAdd an icon. Value is the icon class name. -
Renderable::ICON_PACK => stringAdd an icon. Sometimes icons have packs, such asfasfor FontAwesome. Requires theICONextension too. -
Renderable::LABEL => stringThe field label. -
Renderable::NAME => stringOverrides the html “name” attribute. If you want to do something really special with this data. -
Renderable::PLACEHOLDER => stringUused to fill html placeholder field. -
Renderable::READONLY => boolRender but make it readonly. -
Renderable::SIZE => Renderable::SIZE_LARGE|Renderable::SIZE_NORMAL|Renderable::SIZE_SMALLChange the field size.
See also: