phpScheduleIt
May 21, 2013, 05:48:04 PM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: phpScheduleIt 2.4.2 has been released!
 
   Home   Help Login Register  
Pages: [1]
  Print  
Author Topic: add new field issue  (Read 825 times)
smashdes
Newbie
*

Karma: 0
Posts: 6


« on: November 09, 2011, 12:48:19 PM »

Hi,

I added a new registration field following the guide created by nick.

Everything is ok, but I would like to make a variation..

Instead of creating a registration field like summary so with a text area I would like to create one with a form select..

I copy the code I wrote inside reserve.template.php

Code:
<?php
}

/**
* Tabella per selezionare se il socio ha pagato o no.
* @param string $payment environment to edit
* @param string $type type of reservation
*/


function print_payment($payment) {

if (
Auth::isAdmin()) { ?>

<table width="200" border="0" cellspacing="0" cellpadding="0" class="recur_box" id="repeat_table" style="margin-top:5px;">
    <tr>
      <td style="padding: 5px;">

    <?php
 echo 
translate('Pay') . ' ';
 echo '<select name="payment" id="payment" class="textbox">';
 echo '<option value=" '$payment ' ">' translate('No') . '</option>';
 echo '<option value=" '$payment ' ">' translate('Yes') . '</option>';
 echo '</select>';
 ?>
   
   </td>
    </tr>
</table>



<?php
}
}

As you can see I need only 2 options..

But if I save it doesn't save anything into the database.

I explain how it should work.

Like default value I want the option NO
so everytime I save it should write into Database the text NO
only the administrator can set the option YES.

At this moment if I go in phpmyadmin and I go the row of the registration the column called payment is empty


Other question

I would like to add that field to the search option for the administrator.. how can i do that?

Thank you
Logged
Nick
Administrator
Hero Member
*****

Karma: 15
Posts: 5419


WWW
« Reply #1 on: November 14, 2011, 01:59:08 PM »

To get it to save, you'll need to read it off of the page and insert pass it to the query that saves the information.

Making it searchable is a bit more work.  You'll need to add it to templates/usage.template.php, lib/db/UsageDB.class.php and usage.php.  In general it will be similar to what you did for adding it to reserve.
Logged
smashdes
Newbie
*

Karma: 0
Posts: 6


« Reply #2 on: November 14, 2011, 02:46:11 PM »

To get it to save, you'll need to read it off of the page and insert pass it to the query that saves the information.

how can I do that? what do you mean for read it off of the page etc?

thanks
Logged
Nick
Administrator
Hero Member
*****

Karma: 15
Posts: 5419


WWW
« Reply #3 on: November 14, 2011, 03:01:34 PM »

Pretty much the same steps required for adding the new field.  You'll need to change the files mentioned above to allow that field to be searchable.
Logged
smashdes
Newbie
*

Karma: 0
Posts: 6


« Reply #4 on: November 15, 2011, 07:18:25 AM »

Nick,

my problem now is that the form doesn't write anything inside the DB...

So even if I choose yes or not and click to save inside the database the field Payment is empty..

because in the add new field tutorial is explained how to add a text box but not how to add a select form and I'm not that good with PHP..

thanks for your help
Logged
Nick
Administrator
Hero Member
*****

Karma: 15
Posts: 5419


WWW
« Reply #5 on: November 15, 2011, 11:42:29 AM »

Once we get past the UI, the select box is identical to adding a text box.  The only way it would be different is if you were doing a multi-select box.
Logged
zaky
Newbie
*

Karma: 0
Posts: 17


« Reply #6 on: November 16, 2011, 03:23:56 AM »

Hello Nick,
I am having a similar problem. For me the value of the new fields are writing in the database ( checked with phpadmin) but when I want to modify the reservation, the value of these two new fields is empty.  The first field is a select box and the other is a number ( quantity).
Anything I am doing wrong? Where / which file could I check ?

In advance thank you.
Logged
narongkorn
Newbie
*

Karma: 0
Posts: 2


WWW
« Reply #7 on: November 17, 2011, 08:06:50 AM »

thanks for your help Smiley Huh
Logged
Nick
Administrator
Hero Member
*****

Karma: 15
Posts: 5419


WWW
« Reply #8 on: November 21, 2011, 01:00:55 PM »

You'll need to populate the value of the field from the value in the database.  You should be able to pretty much copy how other fields are working.
Logged
zaky
Newbie
*

Karma: 0
Posts: 17


« Reply #9 on: November 27, 2011, 07:24:18 AM »

Thanks Nick for your response, unfortunately I don't know how to populate the field from the values in the database. Which files should I be looking for?

In advance thank you for all.

Zaky
Logged
alisondesser
Newbie
*

Karma: 0
Posts: 2


WWW
« Reply #10 on: November 27, 2011, 01:34:27 PM »

Like default value I want the option NO
so everytime I save it should write into Database the text NO
only the administrator can set the option YES.
« Last Edit: November 28, 2011, 01:34:04 PM by Nick » Logged
Nick
Administrator
Hero Member
*****

Karma: 15
Posts: 5419


WWW
« Reply #11 on: November 28, 2011, 01:35:05 PM »

For that you should only show the drop down if the user is an admin, otherwise hide it and default it to NO
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2006-2007, Simple Machines Valid XHTML 1.0! Valid CSS!