Custom block with forms

Permalink
Hi,
I want to create a block with a form. Is there an example for such as block?

I need something like this:

view.php

<form action="file.php">
<input ... >
[..]
</form>


I need to display form result in the block - not to redirect to a diffrent page. How to do this? Should I use the controller?

 
Remo replied on at Permalink Reply
Remo
You can check out the guestbook, form or survey block. All of them print a form and process it and then display a text.

Yes, I'd recommend that you handle the data processing the controller.
marjo replied on at Permalink Best Answer Reply
I have something like this:

view.php:

<?php defined('C5_EXECUTE') or die(_("Access Denied."));
$bt = Loader::helper('concrete/interface');
$form = Loader::helper('form');
?>
<form action="<?php echo $this->action('myMethod')?>" method="POST">
      <?php echo $bt->submit(t("Ok"), 'form', 'right', 'primary'); ?>
</form>
        if (!empty($actionAnswer)){
      echo $actionAnswer;
   } else {
      echo 'No action was here';
   }


controller:

<?php defined('C5_EXECUTE') or die(_("Access Denied."));
class MyAbcController extends BlockController {
   protected $btTable = "btBasicTest";
   protected $btInterfaceWidth = "350";
   protected $btInterfaceHeight = "300";
   protected $outmf = "";
   public function getBlockTypeName() {
      return t('abc');
   }
   public function getBlockTypeDescription() {
      return t('A simple testing block for developers');
   }
   public function myMethod(){
      $this->set('actionAnswer', 'Your action is running...');
   }


And it is not working :(

EDIT:
I have changed the name of the controller action method ("action_" prefix). It works!
Remo replied on at Permalink Reply
Remo
Yes, you have to prefix the block controller action methods with action_. You can see that guestbook block too!

<form method="post" action="<?=$this->action('form_save_entry', '#guestBookForm-'.$controller->bID)?>">


function action_form_save_entry() {