Custom block driving me insane

Permalink
hi guyz, im tryng to create a custom block for testing, so i decided to load some data from the user and store it in the database in edit.php (and the same code for add.php) and then from my view.php use that data later.

so, i go to my edit.php and add 2 labels 2 text widgets and a submit following the example block howto and it works until i try to submit because the 2 text never pass the content to the concrete5 created insert operation which ovbiosuly generate errors cuz i have no null fields in the database.

here some of my code maybe you can help me

edit.php

<?php
defined('C5_EXECUTE') or die(_("Access Denied."));
$form = Loader::helper('form');
?>
<?=$form->label('CampaignIDLabel', 'Campaign');?>
<?=$form->textarea('CampaignID', $CampaignID, array('style' => 'width: 320px'));?>
<?=$form->label('DescriptionLabel', 'Campaign Description');?>
<?=$form->textarea('Description', $Description, array('style' => 'width: 320px'));?>
<?=$form->submit('add', 'Add');?>

db.xml database in use

<table name="btItemSlideCampaign">
<field name="CampaignID" type="C" size="255"></field>
<field name="bID" type="I"><unsigned /><key /><autoincrease /></field>
<field name="fID" type="I"><unsigned /></field>
<field name="Description" type="C" size="255"></field>
</table>

the problem is that on submit CampaignID and Description are always null

plz help

 
jordanlev replied on at Permalink Reply
jordanlev
It's probably that you're adding your own submit button, which isn't going to do anything. You don't need to add a submit button because Concrete5 automatically includes that for you (you're just providing the html that goes into the middle of the add/edit dialog).

Another possibility is that your "bID" field is not the first one defined in db.xml -- this is probably not a problem, but just in case try swapping that line with the one above it in db.xml, then go to Dashboard -> Add Functionality, click on the "Edit" button next to your block, then click "Refresh").

A third option is that there is something going on in your controller's save() method -- can you post the controller.php code here as well?

-Jordan
jrch2k10 replied on at Permalink Reply
well the submit doing nothing but be exposed by the api is kinda creepy but ok, but i tried without it and pressing update wich comes with the edit form and still adodb throw an exception claiming that all the values in the sentence are NULL.

ill try making Bid the first table item and check it out
jordanlev replied on at Permalink Reply
jordanlev
Not sure why it's "creepy", but to each their own :)

I think you should just ZIP up the whole block and post it here as an attachment. The errors you're mentioning are not normal and I'm sure there's just a typo or a simple error somewhere, but I need to see the code to be able to determine that.
jrch2k10 replied on at Permalink Reply
well i don't have done anything else with the code, process.php is standard

class ItemSlideBlockController extends BlockController {
protected $btDescription = "A colorful way to present Items";
protected $btName = "ItemSlide";
Protected $btTable = "btItemSlideCampaign";
}
?>

as you can see

concrete5 is in the latest version
kubuntu maverick
cherokee tried with apache2 too same thing
php5 latest update
jordanlev replied on at Permalink Reply
jordanlev
I can't tell what the problem is from what you've posted. If you can ZIP up your entire block and attach it here I would be happy to take a closer look, otherwise I unfortunately can't help.
jrch2k10 replied on at Permalink Reply
well it kinda solved itself, i removed the database and uninstalled the block and installed it again and it works now (weirdly the database structure export is the same as before unistall so i guess something related to the cache was wrong but i have it disabled since is a pain with CSS when you are actively theming).

but it doesn't work as i expected aka i want to create a custom block for handle my banner/publicity(but instead of png im using it with svg and js since i don't give a damn about ie compatiility)so i need to create several campaigns in the top form of edit.php and in the second half the several svg art path linked to that specific campaignID, so in the view i just select for that block instance the text and svg images for that campaingID that will show(kinda like slideshow but closer to gavick component for joomla) and even maybe wich effect use.

but as it is by default it insert the first time but after is sent update instead of insert and always iterate over the same db register, so can you point me out a way to disable/bypass/rewrite the current c5 way of handle thing for add/edit.php?? is not a problem if i have to rewrite the logic for my block

thx for your help
jordanlev replied on at Permalink Reply
jordanlev
Not sure I understand exactly what you want to do here. It sounds like you want to be able to add a block and then enter in campaign ids and images created by svg (??), and show those in a slideshow of some kind?

Or do you have a whole bunch of campaigns and artworks that is shared across the entire site, and every time you add a block you want to be able to choose just some of the campaigns from that complete list?

Or something else?
jrch2k10 replied on at Permalink Reply
is part of both actually.

for example i want to have my component in the front page showing some nice looking svg art with a short text description and some cool css3 animations, wich i previously organized in "my company" campaign id(ovbiously linked togheter) and in the product page the same type of component showing "my product" art and then another to do some publicity to products/brands i distribute in some another random page, etc

so far i think i found a way to do it bypassing entirely edit/add.php and creating a custom dashboard page to do all the data lift and in the component just use view.php and the bID of that specific component wich i get inquiring the block table from the dashboard and harcoding the campaignid with that bid, i think it should be automatic enough to get the job done :) i hope