TOPIC:

Re: Populate Fields from Database Table 11 years 9 months ago #22576

  • SpikeWeb
  • Offline
  • Fresh Breezer
  • Fresh Breezer
  • Posts: 1
  • Thanks: 0
Hi,

Thank you for a great solution. One problem I am having is populating a select list. I have imported the value from the DB and exploded it and then have used variations of the below code to try and determine which elements are selected.

<?PHP return (in_array('junior-school', $areasofInterest)) ? "1" : "0"; ?>;Junior School;junior-school
<?PHP return (in_array('senior-school', $areasofInterest)) ? "1" : "0"; ?>;Senior School;senior-school
<?PHP return (in_array('sport', $areasofInterest)) ? "1" : "0"; ?>;Sport;sport
<?PHP return (in_array('music', $areasofInterest)) ? "1" : "0"; ?>;Music;music

I have tried many different subtlties here but no luck. How would you acheive this?

Thanks

Please Log in or Create an account to join the conversation.

Re:Populate Fields from Database Table 7 years 11 months ago #127436

  • neontetra
  • Offline
  • Junior Breezer
  • Junior Breezer
  • Posts: 33
  • Thanks: 1
I know this is an old post but I am new. I got the original code to work in my Begin Form section but since I have about 8 forms I wanted to use it on, I tried convert it a piece. I copied the exact code over into a piece as below.

function ff_populate_trips(){
$this->execPieceByName('ff_InitLib');

$test = "";
for ($i = 0; $i < 10; $i++) {
$test .= "0;Product {$i};value{$i}\n";
}

function ff_setSelectList($name, $value){
global $ff_processor;
for ($r = 0; $r < $ff_processor->rowcount; $r++) {
$row =& $ff_processor->rows[$r];
if ($row->name==$name)
$row->data2 = $value;
unset($row);
} // for
} // ff_setSelectList

ff_setSelectList('select', $test);

}

called called it from Begin Form like this
$this->execPieceByName('ff_populate_trips');

But it does nothing. I worked fine in Begin Form but now does not work. I'm thinking that it has something to do with ff_setSelectList('select', $test); but I am not sure what. Maybe the element 'select' needs to be passed differently but I cannot find how. Any ideas?

Please Log in or Create an account to join the conversation.

Re:Populate Fields from Database Table 7 years 11 months ago #127439

  • neontetra
  • Offline
  • Junior Breezer
  • Junior Breezer
  • Posts: 33
  • Thanks: 1
I posted this to the wrong thread sorry.

Please Log in or Create an account to join the conversation.

Populate Fields from Database Table 6 years 11 months ago #156381

  • saki.sk
  • Offline
  • Fresh Breezer
  • Fresh Breezer
  • Posts: 9
  • Thanks: 0
Hi
I need to populate fields from Content builder storage.
I have Content builder storage and a view. Each record produces an Article.
At front end view there is an order form at the bottom of an article.
This order form runs as module in iframe mode.
I need to populate some fields from Content builder storage belonging to the article title.
I have made this code, but it does not work:
Before Form Piece:
$input = JFactory::getApplication()->input;
$myid = $input->getInt('id'); //get the article ID

$databasea=JFactory::getDBO();
$databasea->setQuery("SELECT * FROM #__content WHERE id = '$myid'");
$rowa = $databasea->loadObjectList();
$recorda = $rowa[0];
$article = $recorda->title; //get the article title

global $database, $record;
$database=JFactory::getDBO();
$database->setQuery("SELECT * FROM #__[CB_sorage] WHERE title = '$article'");
$row = $database->loadObjectList();
$record = $row[0];
Form Values:
<?php global $record; return $record->[column_name]; ?>
Of course [CB_sorage] and [column_name] - there are real names. My console shows more of this errors:

BF-Trace
<strong>*** EXCEPTION CAUGHT BY BREEZINGFORMS ***</strong>
PHP error level : E_NOTICE
PHP filename : D:\a_WEB\JoomlaTesting\components\com_breezingforms\facileforms.process.php(1241) : eval()'d code
PHP linenumber : 6
Last known pos : Before form custom piece code at line 1
Error message : Undefined offset: 0


<strong>*** EXCEPTION CAUGHT BY BREEZINGFORMS ***</strong>
PHP error level : E_NOTICE
PHP filename : D:\a_WEB\JoomlaTesting\components\com_breezingforms\facileforms.process.php(1241) : eval()'d code
PHP linenumber : 7
Last known pos : Before form custom piece code at line 1
Error message : Trying to get property of non-object


Can you help me please? I am PHP beginner.
Jaroslav

Please Log in or Create an account to join the conversation.

Populate Fields from Database Table 6 years 11 months ago #156382

  • pedro81's Avatar
  • pedro81
  • Offline
  • Ultimate Breezer
  • Ultimate Breezer
  • Posts: 15273
  • Karma: 287
  • Thanks: 1077
Hi,

just a fast hint: enter this code line at the beginning of your Before Form Script:
$this->execPieceByName('ff_InitLib');

Please Log in or Create an account to join the conversation.

Populate Fields from Database Table 6 years 11 months ago #156502

  • saki.sk
  • Offline
  • Fresh Breezer
  • Fresh Breezer
  • Posts: 9
  • Thanks: 0
Hi,
Including BreezingForms Library does not help at this case.
I mean, the problem is that my form is running in an iframe.
And there is no passing post information from parent window to this iframe.
So my code in the Before Form Piece cannot get the article id.
I have tried to modify file: "components\com_breezingforms\breezingforms.php to add article id to the iframe url:
.'&amp;id='.JRequest::getInt( 'id', 0);
and now I have the article id at the end of iframe url.
But my code in the Before Form Piece is still unable to retrieve this id and does not work.
Can you help me - how can I pass the article ID to my code in iframe?

Please Log in or Create an account to join the conversation.

Last edit: Post by saki.sk.
Moderators: ForumSupport
Time to create page: 0.046 seconds

BreezingForms Pro 1.4.7 for WordPress Released!

Available in the membership section.

September Discount!

Massive discounts on all subscriptions!

Get Your Subscription Here

Quick Links

Downloads

BreezingForms

ContentBuilder

BreezingCommerce

Templates

Documentation

BreezingForms

ContentBuilder

BreezingCommerce

Apprendre BreezingForms (French Community)

Apprendre et maîtriser BreezingForms par des tutoriels et exemples, le tout en français

breezingforms.eddy-vh.com

Questions et réponses sur les forums de l'AFUJ

AFUJ

Special Offer

Summer Sale! All subscriptions at a special price!

Includes prio support, all of our current and future Joomla!® extensions and Joomla!® templates for the duration of your membership.

Get it from here

3rd Party Discount - 25% Off

We help you to keep your costs under control. If you are a new member and purchased a form building tool from a different form vendor, then you'll get a 25% discount on our subscription plans.

How to receive the discount:

Send us a quick email to sales@crosstec.org with a proof of purchase (for example a paypal receipt), await payment instructions and enjoy your membership!