Welcome Guest, Not a member yet? Register   Sign In
CodeExtinguisher Release Candidate 11
#91

[eluser]minimal design[/eluser]
sorry for the noob question, I'm more of a design/frontend kinda guy... Wink

Do you need to create a controller for all the definition YAML files you create?


I'm asking because as soon as I add a YAML file with the name of one of my tables in my DB, I get "An Error Was Encountered. You must define a table name in your controller." whereas I can CRUD all I want on that same table without the YAML file in the definitions directory. I'm asking because I'm following along you screencast and it doesn't seem that you add a constructor when you add your "cars.yml" file...

Sorry again for the lame question... I did read the docs and this whole thread, I know PHP, but the whole MVC/framework thing is new to me so I'm still fighting to get over the initial learning bump Smile
#92

[eluser]Majd Taby[/eluser]
First off, make sure you have the latest version of codex (from this thread).

There are two ways to setup a codex page.

1) If you want to have it automatically created for you, then you don't need to do anything. CodeExtinguisher will "guess" what your form elements are.
If you want to customize the form, then you just need to create a YAML file with form_setup (as in the screencast) defined. (use related_example.yml as a template)

2) If you want to write your own controller (so that you can define your own callbacks or special behaviour), then open the example.php controller, and use that as a template.

Let me know if I answered your question, I was having a little bit of trouble understanding your post.
#93

[eluser]minimal design[/eluser]
Basically, my question was: do I need to add a controller file when I add a YAML file.

EDIT: cool, for some reason, in the screencast, you can't see the first part of the YAML file:

Quote:db_table:related_example
controller_name: CRUD
page_header: Related Example


It's all working fine now. Thanks for the feedback!
#94

[eluser]Majd Taby[/eluser]
@minimal, You shouldn't have to define those extra ones. Are you sure you're using the latest release candidate?

@andjules, The way you have specialized forms for add and edit is by creating your own controller, and supplying the form in the add and edit functions. For example:

Code:
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
/*
*
* NOTE:
*   This controller does not generate tables, you must predefine you table.
*
*/
include("codexcontroller.php");

class Example extends codexController
{
    function Example ()
    {
        codexController::codexController();
        $this->construct('my_table_add.yml');
    }
    function construct($file){

        $config = array(
                    'db_table' => 'example',
                    'form_setup' => $this->spyc->YAMLLOAD('definitions/'.$file.'.yml'),
                    'controller_name' => 'Example',
                    'primary_key' => 'my_id',
                    'display_fields'=>array('textbox_test','related_example','dbdropdown_test','date_test','sessiondata_test')
                    );
        $this->setConfig($config);
    }
    function add(){
        $this->construct('my_table_add.yml');
        codexController::add();
    }
    function _edit(){
        $this->construct('my_table_edit.yml');
        codexController::_edit();
    }
}
?>

Do note that this code is just whipped up, so I can't guarantee it'd work as-is
#95

[eluser]Comter[/eluser]
I think I'm still missing something. No matter what I do I can't seem to get rid of the example table. I remove the example table but then I get a database warning saying that it can't select the example table fields. If I remove the example controller then I at least get a login prompt but after I login I get a 404. Is it something to do with the login success redirect? Is there a default CRUD controller that it needs to redirect to? What places in the code do I need to change to remove the example?

-the purring dork
#96

[eluser]Majd Taby[/eluser]
There are a few things you need to do (I'm working (along with Thoer) on removing a lot of these steps)

1) Remove the table from your database
2) Delete example.php from your controllers/ folder and example_form.yml from the definitions/ folder
3) Remove the link from navigation.php in your views/ folder
4) Update your login_success_redrect (config/config.php) and the default controller (config/routes.php)
#97

[eluser]GDmac - expocom[/eluser]
Hello, jTaby. I was starting with CE today and took me some time to work thru the different
and settings. Great tool if you get the hang of it but it is not easy to start in a easy way.
the example is a table, but has a controller, is excluded in auto-crud, but is hard-wired
into navigation (view) and set as default in the routes :-)
--
Then there is YAML. I think would also be great if it where documented a bit more.
in related_example.yml there are rules and a form_setup but in example_form there
is a general_information with fieldset and params: form (my head started spinning)
is there some (extended) documentation? params, fieldsets, forms etc.
--
the OneToMany plugin uses $this->local_table.'_id' for the remote key but
the remote key is different (custom) on some of my tables, how would i
set a remote_key thru the yml for a OneToMany?
#98

[eluser]Majd Taby[/eluser]
GDmac, I apologize for making your head spin Smile

Documentation is the area where codex is lacking greatly. I'm picking at it, and you can see my progress at http://codeextinguisher.pbwiki.com
If you could tell me all the areas you found confusing, that would be awsome. What happens is that I spend so much time in codex, I get really familiar with it, and I lose track of what's easy to understand and what's not.

As far as the OneToMany issues, that's one of the issues that will get addressed soon.
#99

[eluser]abmcr[/eluser]
I also am a beginner with CodeExtinguisher.... please excuse me for my questions and my english language

1) It is possible to insert into the edit form (the view created with the yml) a free text, a text not retrieved from the db?
2) i want manage a gallery of photo: i have two table (galleries and photos - OneToMany)... in the many yml it is possible to insert an upload field?

Thank you for your very useful contribution.... Ciao!!!

Andrea

[eluser]Majd Taby[/eluser]
abmcr, no worries Smile

1) If you mean you want to just enter some text, then you can write your own plugin

2) Not now, but it's a bug i'm working on.

p.s. don't forget to translate codex to (italian?) Tongue




Theme © iAndrew 2016 - Forum software by © MyBB