# Forums | Mahara Community

## Developers / [PHP] Creating a textbox block through code

Deleted user
Posts: 4

15 August 2014, 12:04 AM

Hi everyone,

I've been struggling to create a  textbox block through PHP code. At first I thought something like this would be enough:

foreach ($data as$key => $valor){$posts = new BlockInstance(0, array(
'blocktype' => 'textbox',
'title' => $key, 'row' => 1, 'column' => 1, 'order' =>$i,
'configdata' => array(
'text' => $value ), ); i++;$view->addblockinstance(\$posts);
}

but as it turns out, that doesn't work, it only gives me empty blocks with titles because, apparently, I need to create a textbox artefact first. Would you be so kind to guide me through the process? I think it should be pretty simple.

Posts: 99
##### Re: [PHP] Creating a textbox block through code

19 August 2014, 6:29 PM

Hi Daniel,