Love Fuel?
Donate
About
Forums
Discussions
Login
FuelPHP Forums
Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
General
form select via ORM
satriawae
June 2015
I want to follow instruction from
here
I Generate via oil scaffold, and then want to modify some form-input into form-select
in my controler action_create
$data['kdbrgs']=Model_Kdbrg::find('all);
$this->template->content = View::forge('kdbrg/create',$data);
View create
<?php echo render('kdbrg/_form'); ?>
View _form
<?php echo Form::select('kdbrg', 'none', \Arr::pluck($kdbrgs, 'name','code')
); ?>
and then I get error message
Undefined variable: kdbrgs
but when I change my code to:
n my controler action_create
$data['kdbrgs']=Model_Kdbrg::find('all);
$this->template->content = View::forge('kdbrg/
othercreate
',$data);
View
othercreate
<?php echo Form::select('kdbrg', 'none', \Arr::pluck($kdbrgs, 'name','code')
); ?>
it works..,
I used to use in my view from standar oil scaffoling
DB::select()->from('kdbrg')->as_array ()
but as the forum suggest it's not safe to do that, I want to change the way I make select
can someone explain it for me how to do it correctly
to make my apps more secure??
regards.., thanks for any advise
:)
Harro
June 2015
Accepted Answer
Your first example uses sub-views, and data isn't automatically inherited by those views. The fact that you pass a variable to "kdbrg/create" doesn't mean "kdbrg/_form" can see it, so you need to pass it on.
To do that, change
<?php echo render('kdbrg/_form'); ?>
to
<?php echo render('kdbrg/_form', array('kdbrgs' => $kdbrgs)); ?>
satriawae
July 2015
:D
it works..,
deeply thanks
@Harro
Add a Comment
Howdy, Stranger!
It looks like you're new here. If you want to get involved, click one of these buttons!
Sign In
Apply for Membership
Categories
All Discussions
5,088
General
↳ General
3,364
↳ Job Board
13
↳ Installation & Setup
214
Packages
↳ Oil
213
↳ Orm
700
↳ Auth
260
Development
↳ Tips and Tutorials
126
↳ Code share
145
↳ Applications
52
In this Discussion
Harro
June 2015
satriawae
July 2015