-
Notifications
You must be signed in to change notification settings - Fork 1
ComNinjaFormParameter example
Lets say you got this view: admin::com.foo.view.bar
and wants to quick and easy render an example form just to see how the elements works.
The following example show you how to create this result:
In this file: administrator/components/com_foo/views/bar/html.php
Put this: $document = KFactory::get('lib.koowa.document'); $filepath = dirname($this->getIdentifier()->filepath).'/tmpl/params.xml'; $model = KFactory::get($this->getModel()); $bar = $model->getItem(); $this->form = KFactory::get('admin::com.ninja.form.parameter', array( 'data' => $bar->params, 'xml' => $filepath ));
$document->addScript('http://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js');
$document->addScript('http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/jquery-ui.min.js');
$document->addStyleSheet('http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.0/themes/base/jquery-ui.css');
$document->addStyleSheet('http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.0/themes/overcast/jquery-ui.css');
The scripts are for the jquery powered elements we got that isn't ported to our new assets system yet. Once they are, you can safely remove the addScript and addStyleSheet calls in this example.
Then in your params.xml file (see: $filepath) have this:
Ninjaboard Content Info Error Ninjas Pirates Vikings Ninjas Pirates VikingsAnd then in your layout where you want the form to output, do something like the following:
This is an extremely simple example just to get you started. You're able to do much much more than this.
For instance, the data option, accepts arrays, objects, json strings and INI formatted strings.
The xml option accepts an path to an xml file, and xml string or an SimpleXMLElement object.
This is just the tip of the iceberg, and we'll talk about the other aspects of what you can do, in other pages as it's outside the scope of this tutorial.
