Saving Form data from custom block
Permalink
Hello y'all,
I have been working on a custom block that saves events. It is apart of a event creation and attendance system that I am making and I am having trouble capturing the data that the user inputs from the form displayed in the block and saving it to my database table. So I need some pointers... Here is my code:
controller.php
view.php
I have been working on a custom block that saves events. It is apart of a event creation and attendance system that I am making and I am having trouble capturing the data that the user inputs from the form displayed in the block and saving it to my database table. So I need some pointers... Here is my code:
controller.php
<?php defined('C5_EXECUTE') or die("Access Denied."); class DuasNewEventBlockController extends BlockController { protected $btTable = "btDuasEvents"; protected $btInterfaceWidth = "350"; protected $btInterfaceHeight = "350"; public function getBlockTypeDescription() { return t("This is a block to create events"); } public function getBlockTypeName() { return t("DUAS - New Event"); } public function save($data){ parent::save($data); }
Viewing 15 lines of 24 lines. View entire code block.
view.php
<?php defined('C5_EXECUTE') or die("Access Denied."); ?> <?php print_r($_POST); $form = Loader::helper('form'); ?> <form method="post" action="<?php echo $this->action('form_save_event', '#new_event_'.$controller->bID)?>"> <?php echo "<h2>" . t('Create a new event —') . $u->getUserID(); echo '<h2>'.t('Event name').'</h2>'; echo $form->text("event_name", $event_name); echo '<h2>'.t('Event type').'</h2>'; echo $form->select('event_type', array('manditory' => 'Manditory', 'voluntary' => 'Voluntary'), 'manditory'); echo '<h2>'.t("Event Date").'</h2>'; echo $form->text("event_date", date('Y-m-d H:i:s')); echo $form->hidden('bro_id', $u->getUserID());
Viewing 15 lines of 19 lines. View entire code block.

Can you post the db.xml
I just posted the XML DB file! Let me know what you think
Here is the XML DB file:
<?xml version="1.0"?> <schema version="0.3"> <table name="btDuasEvents"> <field name="bID" type="I"> <key></key> <unsigned></unsigned> </field> <field name="event_name" type="C" size="45"></field> <field name="event_type" type="C" size="45"></field> <field name="event_date" type="T"></field> <field name="bro_id" type="I"></field> </table> </schema>