Files
nibiru-framework.com/core/c/form.php
Stephan Kasdorf 86433af5bf Version 0.3 beta 04.02.2018
Improved: The Router now accepts actions, either trough the _action as parameter, or on the URL pattern after the controller name Example: http://youdomain/[controllername]/[actionname]/
It is now possible to load as many navigations on the page as wanted by passing the name to the JsonNavigation::getInstance()->loadJsonNavigationArray('[NAME]'); call in the navigationAction of the Controller
Building forms by simple adding the namespace use Nibiru\Factory\Form; and calling Example: Form::addInputTypeText( array( 'name' => 'lastname', 'value' => 'placeholder' ) ); To finalize the form the last call should be something like this: Form::addForm( array('name' => 'testform', 'method' => 'post', 'action' => '/' . Router::getInstance()->currentPage(), 'target' => '_self') );
The Database design has fully been refactored, now it contains an autoloading mechanism which can be triggert by createing a database folder in the application folder, a Example file is in the folder applicatoin/database
The Database access can now be implemented anywhere in your application by adding the namespace to your database accessing Logic: use Nibiru\Factory\Db;
2018-02-04 22:16:21 +01:00

69 lines
1.4 KiB
PHP

<?php
namespace Nibiru\Form;
use Nibiru\Adapter;
/**
* Created by PhpStorm.
* User: mithril
* Date: 26.01.18
* Time: 20:59
*/
class Form implements IForm
{
private $_attributes = array(
self::FORM_NAME => '',
self::FORM_METHOD => '',
self::FORM_ACTION => '',
self::FORM_TARGET => ''
);
private $_element;
public function loadElement( $attributes )
{
$this->_setElement();
$this->_setAttributes( $attributes );
return $this->getElement();
}
/**
* @return array
*/
protected function getAttributes( )
{
return $this->_attributes;
}
/**
* @param array $attributes
*/
private function _setAttributes( $attributes )
{
foreach( $attributes as $key=>$entry )
{
switch ($key)
{
case array_key_exists($key, $this->_attributes):
$this->_element = str_replace(strtoupper($key), $entry, $this->getElement());
break;
}
}
}
/**
* @return mixed
*/
protected function getElement( )
{
return $this->_element;
}
/**
* @param mixed $element
*/
private function _setElement( )
{
$this->_element = '<form action="ACTION" method="METHOD" name="NAME" target="TARGET">' . "\n" . 'FIELDS</form>' . "\n";
}
}