creating a new block
PermalinkI added this code to add.php and edit.php
<div class="ccm-ui">
<?php echo $form->label('sentence', t('Input Sentence')) ?>
<?php echo $form->text('sentence') ?>
</div>
And I added this code to db.xml
<field name="sentence" type="X2">
<default value="" />
</field>
What else do I need to do to make sure that whatever I plug into Input Sentence (which appears in the edit-block screen as a form field, but doesn't display or save my input when I view the block afterward) dsiplays in the block and remains in the database table for the block?
So, it turns out that simply adding the form to the add.php and edit.php files and adding the new column for the database to the db.xml file DOES NOT automatically trigger code to make a new column in the database. So, I went into the database and added one. Now it it works. Here are the steps for newbies like myself.
1. add form to edit.php and add.php (if the form helpers are confusing just copy their syntax
2. make new fields/columns in the xml.db file
(See code above).
3. add those same columns/fields to the actual database using php my admin.
Below I am pasting all code before and after and a screenshot
<?php defined('C5_EXECUTE') or die(_("Access Denied.")) ?>
<div class="ccm-ui">
<div class="alert-message block-message info">
<?php echo t("This is the add template for the basic test block. Anything you add in this view will automatically be wrapped in a form and, when submitted, sent to the block's controller.") ?>
<?xml version="1.0"?> <schema version="0.3"> <table name="btBasicTest"> <field name="bID" type="I"> <key ></key> <unsigned ></unsigned> </field> <field name="content" type="X2"> <default value="" ></default> </field> <field name="sentence" type="X2"> <default value="" ></default> </field> </table> </schema>
see attached jpeg for php my admin steps
or is this idea counter to the idea of "make a block for a relatively specific purpose, use it for that purpose or make a new one?"
More info:http://www.concrete5.org/documentation/recorded-trainings/building-...
Jordan Lev has contributed this to the community. It's available at no cost at:http://www.concrete5.org/marketplace/addons/designer-content/...