I have a job to import excel file and save the data to database via cakephp, the probleme is, this application allow user to choose the table that he want to used to save the data from excel file, so i need to list all the model name, i have search through google how to get all model name but i can't find it. I just can get all the table name, but this is not enough. I must know all the model name, please help me...
I can get all the field name uses this code:
$this->loadModel('Person');
$fieldsArray=$this->Person->find('all');
$fieldsArray=Set::extract('/0/Person',$fieldsArray);
$fieldNames=array_keys($fieldsArray[0]['Person']);
debug($fieldNames);
but as you can see, i have to know the model name, i can't solve this problem, please help me..
Best regards...
$Model = App::objects('Model');
pr($Model);
Do you mean:
$allModelNames = Configure::listObjects('model');
pr($allModelNames);
Note:
This only works for CakePHP1.x
For CakePHP2.x please use App::objects() instead.
Related
I have a Profile Type attached to a user. In there I have a Entity Reference Field of Program Manager. I have Live Events(content-type) that people can register for. I set up a Rule to Email the Program Manager every time someone registers.
My problem is I am trying to pull information from the Profile based on the the entity reference for the Program Manager.
I have the field printing out by using this pattern...
[registration:entity:field_program_manager]
However when I try to pull the first name, email of phone I can not get it to show up.
Does anyone have any ideas to share?
Many Thanks!
Okay so I was trying to solve for sending the email to the Author of the page but was having issues. So I created a new fields hoping it would be easier. In trying to solve for this I solved the original issue.
To print the Author of a node to an email through Rules actions us this.
[registration:entity:author]
So for first name it would be:
[registration:entity:author:profile-main:field_first_name]
Hope it helps someone else.
If you're using entityform instead of a node and referencing the default user info (not the 'Main Profile' profile type), then you want to use something like
[entityform:field-staff-entity-ref:field-work-email]
In this case, 'field-staff-entity-ref' is the entity reference field in the entityform and 'field-work-email' is the field in the user's account settings.
I have created a dataset user in logical data model and publish it. Then, I wanted to connect the dataset in GD Writer, but in select box the dataset is not supported to be select. Does someone know where is the problem?
Thank you very much!
It is probably with setting the right ${GDC_PROJECT_ID} parameter in workspace.prm file.
I have three tables/models:
User(id)
Map(id, user_id, attribute_id)
Attribute (id, name)
Map belongsTo the others, the others hasMany Map.
I'd like the user (via user controller and user view) to create many links to associations at once. How can I do this, assuming that the user forms (add/edit) have 10 attribute fields, all linking to the same table?
I'd need to save up to 10 records in Map in one go. To start with, I'm unsure what the field should be - create('Attribute.name')? Also, cake outputs the same input name to each input as they point to the same field - what's the best way to fix this?
I have already read the relevant documentation, but didn't get much from it.
Thanks!
You can use saveAssociated() method. Prepare an input array according to the instructions given in the link and directly use $this->User->saveAssociated($your_array, array('deep' => true));
I'm a bit thumped on this one. On my site: www.mystorkparty.com a user creates a large registry for her baby shower. Is there anyway to create and save a populated registry and then let the user can just click auto populate and her registry form has a pre-populated form which she can edit further?
Thanks in advance.
Do you mean pre-defined code for a form? In that case, yes you can. Rails was meant to keep repetitive coding at a minimum and you can just create your own .gem file like "myForm.gem" that will generate the proper code for you and route it to a controller giving you the MVC structure.
I developed small CakePHP application, and now I want to add one more table (in fact, model/controller/view) into system, named notes. I had already created a table of course.
But when I run command cake bake model, I do not get table Notes on the list. I can add it manually, but after that I get some errors when running cake bake controller and cake bake view.
Can you give me some clue why I have those problems, and how to add that new model?
I would also check your app/config/database.php to ensure that you are using the correct database configuration. You may well have added the table to a different database perhaps and the bake is picking up the other database. Also, and this may be obvious, but check you are in the right project, it's easy to be in a different folder and not realise, especially if you have lots of projects.
I'm not aware of a limit on the bake listing. I would check your database to make sure the table exists and has some columns. You can always open up the console bake script and check for a limit and increase it if needs be.
I found solution!
I had to delete all from cache directory, /app/tmp/cache/models
Now it works!
:-)
When you say added it manually, do you mean added the note.php model? If not, you may want to try that. Verify that the model name is correct for the following:
file name: note.php
class name: class Note extends AppModel
table name: notes
Also, be sure the notes table has the id column and it is set to primary key.
If this does not push you in the right direction, please post your notes table schema here. Also, have you had success in baking other things in your app? Have you upgraded anything?
Please change the following farameters to bake:
For Controller:
/cake/console/libs/tasks/controller.php
function listAll($useDbConfig = 'default') {
change to :
function listAll($useDbConfig = 'YOUR DB CONFIG NAME') {
NOW DO CAKE BAKE for CONTROLLER! ENJOY!