Oh no! Where's the JavaScript?
Your Web browser does not have JavaScript enabled or does not support JavaScript. Please enable JavaScript on your Web browser to properly view this Web site, or upgrade to a Web browser that does support JavaScript.
Not a member yet? Click here to register.
Forgot Password?

Whats shall a page contain to make a form working

Asked Modified Viewed 3,688 times
C
cis5448
C
  • Junior Member, joined since
  • Contributed 18 posts on the community forums.
  • Started 6 threads in the forums
  • Started this discussions
asked
Junior Member

I have been trying to make my own form with the build-in form generator in v9
I miss a little documentation, on those things
For ex to
How do i get required to work...
What files should be included
A list of form elements and their variables

Is this possible??
0 replies

13 posts

F
Falk
F
Falk 131
Need help?, Having trouble?
• View our Documentation for Guides, Standards and Functions
• Name and Organize your Topics and Content correctly in the corresponding Forums for best support results
• Attaching Log Files and Screenshots when reporting issues will help
• Provide with an URL to live example if one exists
• Please read the How to Report an Error post
• Please read and comply with the Code of Conduct

(¯·._.·(¯°·._.·°º*[ Project Manager ]*º°·._.·°¯)·._.·¯)
  • Super Admin, joined since
  • Contributed 6,201 posts on the community forums.
  • Started 639 threads in the forums
  • Answered 11 questions
answered
Super Admin

Until that part of Documentation is completed, simply look @ examples in the various implementations we provided. There are like 10 bundled Infusions that use that system currently.
0 replies
C
cis5448
C
  • Junior Member, joined since
  • Contributed 18 posts on the community forums.
  • Started 6 threads in the forums
  • Started this discussions
answered
Junior Member

Quote

Until that part of Documentation is completed, simply look @ examples in the various implementations we provided. There are like 10 bundled Infusions that use that system currently.
- by Falk


Thx, but can you help med to get validation to work, cant find what to do in those infusions, it do not show a message that i have missed to input values
openside("");
echo openform("opret_aktivitet","POST",FUSION_SELF."?section=ny_aktivitet",array("class" => "m-t-20"));
   echo "<div class='row'>\n";
   echo "<div class='col-xs-12 col-sm-8'>\n";
echo form_hidden("func","opret");
echo form_text("navn",utf8_encode("AKTIVITET"),"",array(
    'placeholder' => utf8_encode('Angiv navn pÃ¥ aktivitet'),
   'required' => TRUE,
    'width' => '250px',
   'max_length' => 200,
   'error_text' => 'Skal udfyldes',
    "inline" => TRUE
));
   echo form_text('url', utf8_encode("LINK"), "", array(
      "type" => "url",
      "placeholder" => "http://",
      "required" => TRUE,
      "inline" => TRUE
   ));
   echo "</div>\n";
   echo "<div class='col-xs-12 col-sm-4'>\n";
       openside("ELEMENTER");
echo form_checkbox("kategori", utf8_encode("KATEGORI"));
echo form_checkbox("menu", utf8_encode("MENU"));
echo form_checkbox("kontakt", utf8_encode("KONTAKTFORMULAR"),0);
closeside();
echo "</div>\n</div>\n";
echo form_button('opret_aktivitet',"GEM","GEM", array('class' => 'btn-primary m-t-10'));
echo closeform();

i placed 'required" => True, but shall i place a script or am i missing something to to include

Shall button have a special name or....

The rest seems rather easy to do
Edited by cis5448 on 16-05-2016 11:31,
0 replies
C
Chan
C
Chan 0
Lead Developer of PHP-Fusion
  • Super Admin, joined since
  • Contributed 3,841 posts on the community forums.
  • Started 232 threads in the forums
  • Answered 6 questions
answered
Super Admin

Hello, please find the following for your kind perusal:


<?php
/**
 * PHPFusion Infusion Development Tutorial
 * Should you have any questions regarding this tutorial, please forward your concerns in the forum.
 * Please state the line numbers of this gist code when discussing about this tutorial.
 * Provided by MT, PHPFusion.co.uk
 *
 * Please follow the steps 1 to 4 when you practise coding.
 * Notes are written as to why it is as such.
 * Some original codes were altered to show common alternatives.
 */


// STEP 1, init blank values for all your fields
//(1) , point where data value is blank to be passed to form
$data = array(
  "func" => "",
  "navn" => "",
  "url" => "",
  "kategori" => "",
  "menu" => "",
  "kontakt" => "",
);

// STEP 2, do what happens if edit or delete... ?
/*
 * Edit URL: http://www.site.com/infusions/script_infusion/script.php?action=edit&item_id=1
 * Delete URL : http://www.site.com/infusions/script_infusion/script.php?action=del&item_id=1
 */
$edit = false;
if (isset($_GET['action'])) {
    switch($_GET['action']) {
        case "edit":
            if (isset($_GET['item_id']) && isnum($_GET['item_id'])) {
                // (2) point where blank $data is now filled with values from SQL Table.
                $data = dbarray(dbquery("SELECT * FROM ..."));
                $edit = true;
            } else {
                addNotice("danger", "Invalid Item ID");
                redirect(FUSION_REQUEST);
            }
        break;
        case "del":
            if (isset($_GET['item_id']) && isnum($_GET['item_id'])) {
                if (dbcount("(some_id)", SOME_DB, "some_id=''")) { // valid id and delete
                    dbquery("DELETE FROM .....");
                    addNotice("success", "Item deleted");
                } else {
                    addNotice("danger", "Invalid Item ID");
                    redirect(FUSION_REQUEST);
                }
            } else {
                addNotice("danger", "Invalid Item ID");
                redirect(FUSION_REQUEST);
            }
        break;
    }
}

// Step 4,  Finally do what happens button is executed a step before openform() to read previous form settings session variables.
if (isset($_POST['opret_aktivitet'])) {
    // This is the question how to validate in Php-Fusion 9
    // Answer is like this, run form_sanitizer for everything..
    $data = array(
        "func" => form_sanitizer($_POST['func'], "", "func"), // post value, default value, input_name
        "navn" => form_sanitizer($_POST['navn'], "", "navn"),
        "url" => form_sanitizer($_POST['url'], "", "url"),
        "kategori" => form_sanitizer($_POST['kategori'], "", "kategori"),
        "menu" => form_sanitizer($_POST['menu'], "", "menu"),
        "kontakt" => isset($_POST['kontakt']) ? 1 : 0, // if validation not needed, just do like this fastest result
    );

    // Use this to stop Insertion/Update to push $data downwards without refresh to see errors on input
    if (\defender::safe()) {
       if ($edit == true) {
           dbquery_insert(DB_SOMETHING, $data, "update");
       } else {
           dbquery_insert(DB_SOMETHING, $data, "save");
       }
        redirect(FUSION_REQUEST); // Please refresh the page to reload page for new token for the form & security reason
    }
}


// STEP 3, draw form and assign $data value from either (1) or (2)
openside("");

// Minor adjustments - since you need &section, also you need to remember if there is &action, &item_id & $aid too
// The clean_request() is VERY powerful tool for infusion developers.
// If not just use FUSION_REQUEST as next recommended
echo openform("opret_aktivitet","POST", clean_request("section=ny_aktivitet", array("action", "item_id", "aid"), TRUE), array("class" => "m-t-20"));
echo "<div class='row'>\n";
echo "<div class='col-xs-12 col-sm-8'>\n";
echo form_hidden("func", $data['func']);
echo form_text("navn",utf8_encode("AKTIVITET"), $data['navn'],array(
    'placeholder' => utf8_encode('Angiv navn pÃ¥ aktivitet'),
    'required' => TRUE,
    'width' => '250px',
    'max_length' => 200,
    'error_text' => 'Skal udfyldes',
    "inline" => TRUE
));
echo form_text('url', utf8_encode("LINK"), $data['url'], array(
    "type" => "url",
    "placeholder" => "http://",
    "required" => TRUE,
    "inline" => TRUE
));
echo "</div>\n";
echo "<div class='col-xs-12 col-sm-4'>\n";
openside("ELEMENTER");
echo form_checkbox("kategori", utf8_encode("KATEGORI"), $data['kategori'], array("value" => "y")); // If your value is not 1/0
echo form_checkbox("menu", utf8_encode("MENU"), $data['menu'], array("reverse_label" => true)); // if you want to invert label
echo form_checkbox("kontakt", utf8_encode("KONTAKTFORMULAR"), $data['kontakt']);
closeside();
echo "</div>\n</div>\n";
echo form_button('opret_aktivitet',"GEM","GEM", array('class' => 'btn-primary m-t-10'));

echo closeform();
0 replies
C
cis5448
C
  • Junior Member, joined since
  • Contributed 18 posts on the community forums.
  • Started 6 threads in the forums
  • Started this discussions
answered
Junior Member

Thanks a lot for your help...and it helped a lot

Will try this weekend to complete my mission
0 replies
C
cis5448
C
  • Junior Member, joined since
  • Contributed 18 posts on the community forums.
  • Started 6 threads in the forums
  • Started this discussions
answered
Junior Member

That really helped me a lot to get started....few questions though

i want to make a function to fill a SELECT field, is it a simple array i must make to insert that??

The FILE field how does i get it to upload to a dedicated folder, and whart variables shall as minimum be chosen??
0 replies
F
Falk
F
Falk 131
Need help?, Having trouble?
• View our Documentation for Guides, Standards and Functions
• Name and Organize your Topics and Content correctly in the corresponding Forums for best support results
• Attaching Log Files and Screenshots when reporting issues will help
• Provide with an URL to live example if one exists
• Please read the How to Report an Error post
• Please read and comply with the Code of Conduct

(¯·._.·(¯°·._.·°º*[ Project Manager ]*º°·._.·°¯)·._.·¯)
  • Super Admin, joined since
  • Contributed 6,201 posts on the community forums.
  • Started 639 threads in the forums
  • Answered 11 questions
answered
Super Admin

See the downloads admin, photogallery or news for live examples how to handle files and paths.
0 replies
C
cis5448
C
  • Junior Member, joined since
  • Contributed 18 posts on the community forums.
  • Started 6 threads in the forums
  • Started this discussions
answered
Junior Member

   

// This uploads your photo
if (!empty($_FILES['piktogram']) && is_uploaded_file($_FILES['piktogram']['tmp_name'])) {
               $upload = form_sanitizer($_FILES['piktogram'], "", "piktogram");
               if (empty($upload['error'])) {
                  $data['photo_filename'] = $upload['image_name'];
                  $data['photo_thumb1'] = $upload['thumb1_name'];
                  $data['photo_thumb2'] = $upload['thumb2_name'];
               }
            }
print_p($data);
dbquery_insert(DB_PIKTOGRAM, $data, "save");
// or
dbquery_insert(DB_PIKTOGRAM, $data, "update");
}



$upload_settings = array(
            "upload_path" => BASEDIR.'billeder/',
            'required' => 1,
            'max_width' => $gll_settings['photo_max_w'],
            'max_height' => $gll_settings['photo_max_h'],
            'max_byte' => $gll_settings['photo_max_b'],
            'multiple' => FALSE,
            'delete_original' => FALSE,
            'inline' => TRUE,
            'error_text' => 'FEJL I BILLEDE',
                'ext_tip' => sprintf($locale['photo_0017'], parsebytesize($gll_settings['photo_max_b']), str_replace(',', ' ', ".jpg,.gif,.png"), $gll_settings['photo_max_w'], $gll_settings['photo_max_h'])
         );
         echo form_fileinput("piktogram", "Piktogram", "", $upload_settings);
Edited by Chan on 27-05-2016 04:36,
0 replies
C
cis5448
C
  • Junior Member, joined since
  • Contributed 18 posts on the community forums.
  • Started 6 threads in the forums
  • Started this discussions
answered
Junior Member

Above is the code i have for upload, i makes no errors, but nothing is uploadet
0 replies
C
Chan
C
Chan 0
Lead Developer of PHP-Fusion
  • Super Admin, joined since
  • Contributed 3,841 posts on the community forums.
  • Started 232 threads in the forums
  • Answered 6 questions
answered
Super Admin

I will edit your codes
0 replies
C
cis5448
C
  • Junior Member, joined since
  • Contributed 18 posts on the community forums.
  • Started 6 threads in the forums
  • Started this discussions
answered
Junior Member

Do you anything besides the above
0 replies
C
cis5448
C
  • Junior Member, joined since
  • Contributed 18 posts on the community forums.
  • Started 6 threads in the forums
  • Started this discussions
answered
Junior Member

Where do I put it in:
Edited by N/A on 29-05-2016 08:27,
0 replies
F
Falk
F
Falk 131
Need help?, Having trouble?
• View our Documentation for Guides, Standards and Functions
• Name and Organize your Topics and Content correctly in the corresponding Forums for best support results
• Attaching Log Files and Screenshots when reporting issues will help
• Provide with an URL to live example if one exists
• Please read the How to Report an Error post
• Please read and comply with the Code of Conduct

(¯·._.·(¯°·._.·°º*[ Project Manager ]*º°·._.·°¯)·._.·¯)
  • Super Admin, joined since
  • Contributed 6,201 posts on the community forums.
  • Started 639 threads in the forums
  • Answered 11 questions
answered
Super Admin

Sorry if I don´t get it.but you place it in the file you want to call?.
0 replies
C
cis5448
C
  • Junior Member, joined since
  • Contributed 18 posts on the community forums.
  • Started 6 threads in the forums
  • Started this discussions
answered
Junior Member

Where do I put the upload script in the code(Posts: 2730)
So it saves the filename with all the other fields in the form

Included is a screenshot of the codearea, nothing is getting uploaded
Edited by cis5448 on 29-05-2016 18:06,
cis5448 attached the following file:
2_3.png [No information available / 121 Downloads]
0 replies

Labels

None yet

Statistics

  • Views 0 views
  • Posts 13 posts
  • Votes 0 votes
  • Topic users 3 members

3 participants

F
F
Falk 131
Need help?, Having trouble?
• View our Documentation for Guides, Standards and Functions
• Name and Organize your Topics and Content correctly in the corresponding Forums for best support results
• Attaching Log Files and Screenshots when reporting issues will help
• Provide with an URL to live example if one exists
• Please read the How to Report an Error post
• Please read and comply with the Code of Conduct

(¯·._.·(¯°·._.·°º*[ Project Manager ]*º°·._.·°¯)·._.·¯)
  • Super Admin, joined since
  • Contributed 6,201 posts on the community forums.
  • Started 639 threads in the forums
  • Answered 11 questions
C
C
  • Junior Member, joined since
  • Contributed 18 posts on the community forums.
  • Started 6 threads in the forums
  • Started this discussions
C
C
Chan 0
Lead Developer of PHP-Fusion
  • Super Admin, joined since
  • Contributed 3,841 posts on the community forums.
  • Started 232 threads in the forums
  • Answered 6 questions

Notifications

Track thread

You are not receiving notifications from this thread.

Related Questions

Not yet