⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠

  •     

profile picture

how to integrate auth library & G.Crud together and two or more field in one row?



likhon3k

likhon3k
  • profile picture
  • Member

Posted 01 February 2013 - 10:35 AM

Hello Guys...
It's me Likhon, New in this library and this forum also.

I am totally pleased to get grocery crud library. its really very good to programmer and its taking less time to build up an application. I am trying to working with.

I am facing some problem:

1) I am unable to show two or more input field in a row on add page. Grocery Crud build every database field on individual row. I want to show input filed in add/edit form like this:

Row 1: First Name, Middle Name, Last Name
Row 2: Age, Gender .....
etc.

2) I can use grocery crud and auth library. But I want to integrate both like CMS. data/article will be inserted by user name wise in a single table.

suppose: User: A, B, C in my user list. now whoever login and insert data then automatically inserted his name also.
[url=http://postimage.org/image/ano6o238l/][img]http://s18.postimage.org/ano6o238l/image.jpg[/img][/url]

here user likhon login to application. I want to add this username will be automatically inserted into table list and same as other user.

[url=http://postimage.org/image/yn3avrjvd/][img]http://s4.postimage.org/yn3avrjvd/image.jpg[/img][/url]

when user A will login and insert article/post/data then its name automatically need to inserted into database
when user B will login and insert same thing, its name automatically inserted into database.

like Joomla/Wordpress user based article management.

[img]http://s7.postimage.org/bf2lfdoaf/image.jpg[/img]

I searched more in this forum but unable to find this solution. If any one posted it before than sorry but please give me the solution link.

Please give me a good solution.

likhon3k

likhon3k
  • profile picture
  • Member

Posted 01 February 2013 - 16:11 PM

[quote name='likhon3k' timestamp='1359714911' post='5414']
.....

2) I can use grocery crud and auth library. But I want to integrate both like CMS. data/article will be inserted by user name wise in a single table.

suppose: User: A, B, C in my user list. now whoever login and insert data then automatically inserted his name also.
[img]http://s18.postimage.org/ano6o238l/image.jpg[/img]

here user likhon login to application. I want to add this username will be automatically inserted into table list and same as other user.

[img]http://s4.postimage.org/yn3avrjvd/image.jpg[/img]

when user A will login and insert article/post/data then its name automatically need to inserted into database
when user B will login and insert same thing, its name automatically inserted into database.

like Joomla/Wordpress user based article management.

[img]http://s7.postimage.org/bf2lfdoaf/image.jpg[/img]

I searched more in this forum but unable to find this solution. If any one posted it before than sorry but please give me the solution link.

Please give me a good solution.
[/quote]
--------

I think i solved it now. but not sure completely, trying from last few hours but now its done. but if I am wrong this way then please tell me the right way. I am using codeigniter session procedure with grocery crud library. I am not using auth library here.

solution:

1. $crud->callback_after_insert(array($this, 'log_user_after_insert')); // using this code in main function like article function at controller

2. function log_user_after_insert($post_array,$primary_key)
{
$data=$this->session->all_userdata(); // this will take session username and data.
$username=$data['username']; // i wanted to insert username beside of article

$user_logs_insert = array(

"username" => $username,

);

$this->db->where('id', $primary_key); // compare articles id = article id

$this->db->update('articles',$user_logs_insert); // inserting username into article table by update function

return true;
}


3. create a field on article table by username (if you want to insert username), user_id if you want to insert user_id

5. $crud->unset_fields('username'); add this into article table. it invisible username field form add form.


----

Problem 1 not solved yet. If any one know can share it plz.

likhon3k

likhon3k
  • profile picture
  • Member

Posted 08 February 2013 - 18:18 PM

Victor, I am sorry that I am unable to find out the solution and that is why I am asking here again.

 

How can I show two or more input field in a single row.

 

like row 1: first name, middle name, last name.

 

row2: age, location etc.

 

I found few post but it was not clear to me.


davidoster

davidoster
  • profile picture
  • Member

Posted 09 February 2013 - 00:57 AM

With number 1 I can't help you because I haven't done it, but as a quick tip, all the input fields have a unique id. You can use this to alter the display either via javascript or css.

Number 2. Well what you are asking to be honest has nothing to do with grocery crud library!!!

It has to do with CodeIgniter integrating with auth library! If you search on the web for this you'll find many examples how this can be done!!!

I suggest you look here first: http://benedmunds.com/ion_auth/


likhon3k

likhon3k
  • profile picture
  • Member

Posted 10 February 2013 - 15:46 PM

With number 1 I can't help you because I haven't done it, but as a quick tip, all the input fields have a unique id. You can use this to alter the display either via javascript or css.

Number 2. Well what you are asking to be honest has nothing to do with grocery crud library!!!

It has to do with CodeIgniter integrating with auth library! If you search on the web for this you'll find many examples how this can be done!!!

I suggest you look here first: http://benedmunds.com/ion_auth/

 

Thanks. I solved problem 2 by custom controller.

 

But now I am in problem with 1. If you can then please inform me.

 

Thanks in advance...


mnish

mnish
  • profile picture
  • Member

Posted 03 September 2013 - 18:07 PM

for this purpose you have to create a separate theme. I am giving some suggestion but if I am wrong this way then please tell me the right way.

 

we take default theme ok.

 

1. copy your default theme folder and create a copy.

 

2. rename it i.e. custom.

 

3. open file add and edit.php from view folder

 

in add.php

 

<?php
            $counter = 0;
                foreach($fields as $field)
                {
                    $even_odd = $counter % 2 == 0 ? 'odd' : 'even';
                    $counter++;
            ?>
            <div class='form-field-box <?php echo $even_odd?>' id="<?php echo $field->field_name; ?>_field_box">
                <div class='form-display-as-box' id="<?php echo $field->field_name; ?>_display_as_box">
                    <?php echo $input_fields[$field->field_name]->display_as?><?php echo ($input_fields[$field->field_name]->required)? "<span class='required'>*</span> " : ""?> :
                </div>
                <div class='form-input-box' id="<?php echo $field->field_name; ?>_input_box">
                    <?php echo $input_fields[$field->field_name]->input?>
                </div>
                <div class='clear'></div>    
            </div>

 <?php }?>

 

change this according to your field name like

 

<?php

          foreach($fields as $field)
                {

?>

 

<?php if($field_name == 'first_name' || $field_name == 'middle_name' || $field_name == 'last_name') {  ?>

 

    <div>

<?php echo $input_fields[$field->field_name]->input ?>

 

</div>

 

<?php } ?>

 

<?php } ?>

 

it shows three field in a single row. You can also add some attribute like placeholder etc.