Zend Framework 1.12 - Form Decorator settings

I really like the dl/dt/dd output of Zend Framework for forms, but there came a day when I needed a lot more control over the presentation.

In order to remove the dl/dt/dd I used these settings in the form.

In form/model/edit.php

        $this->setDecorators(array(
            array('ViewScript', array('viewScript' => '/model/form/edit.phtml'))));
        $this->setElementDecorators(array(
            'ViewHelper',
            'Errors',
            'Label',
            array('HtmlTag', array('tag' => 'div')),
            'Description'));

In /model/form/edit.phtml



<?php echo $this->element->contact_first_name ?>

Resulting HTML


<div><label for="name" class="required">Name</label>
<input type="text" name="name" id="name" value="" autocomplete="off"></div>

References

http://framework.zend.com/manual/1.12/en/zend.form.standardDecorators.html
http://devzone.zend.com/1240/decorators-with-zend_form/

CentOS 6.4 VirtualBox with Windows 7 (64-bit) Guest

I have an ASUS laptop with a factory installed version of Windows 7 (64-bit) on the internal hard drive, and CentOS 6.4 running off an external USB drive.

My goal was to use Windows 7 to host as many browsers as possible for testing. For that reason, I needed to be able to have both Windows and CentOS running at the same time.

I used the following commands to map the Windows drive for use with VirtualBox:

As root:


chmod a+rw /dev/sda

As the regular user:

VBoxManage internalcommands createrawvmdk -filename /opt/vbox.disks/windows7.vmdk -rawdisk /dev/sda
VBoxManage storagectl 'Windows 7' --name 'SATA' --hostiocache on

Then I created the virtual machine and assigned it to use the VMDK and booted it up.

Windows 7 Dual-Boot CentOS 6.4 on an External USB Drive

Before you do this, make recovery disk(s) for Windows 7. Unless you already have them. You may want to backup anything you have on the Windows 7 drive, but if you’re only using it to run browsers, you haven’t invested that much anyway. Make sure you have some sort of recovery disks or you will either have to buy them or pay someone to fix your disk. Label the disk. Eventually.

The first thing you’ll need for this is a CentOS 6.4 LiveCD. Go to one of the CentOS mirrors (http://www.centos.org/modules/tinycontent/index.php?id=15) and use the following URL pattern: http://mirror.example.com/centos/6/isos/i386/CentOS-6.4-i386-LiveCD.iso. If you have a 64-bit machine, use x86_64. You can also use a USB to boot, I recommend http://unetbootin.sourceforge.net/

Install CentOS on the external drive. I recommend doing a minimal install to get the boot loader set up, then you can either reinstall or add packages to get the system set up the way you want it to.

Once CentOS is on the drive, try to boot from it. You’ll probably have to press a key (on this Asus laptop it is Esc) to choose which drive to boot from. If it won’t boot, you’ll need to adjust the grub settings.

Apparently you can’t change the Windows 7 boot loader. I’m not going to claim this is an authoritative statement, however, installing grub on the Windows 7 drive caused it to fail to boot with a ‘Hard disk error’ (or something similar). This required the Windows 7 recovery disks to recover.

Therefore, you must put the bootloader on the external drive and configure the BIOS to try to boot from the external drive first, with an option to go to Windows.

The problem I had was that by booting off a USB stick the device numbers were a bit off.

Once I had grub loaded on the external drive, I use the find command to determine how the disk was referenced. Then I manually edited the device.map file and grub.conf files after booting into the LiveCD.

For an Asus laptop with Windows 7 on the internal hard disk, and an external USB disk drive, the device.map file looked like this:

It wasn’t really generated by anaconda since I edited it, but that’s okay.

# this device map was generated by anaconda
(hd0)     /dev/sdb

I edited grub.conf using hd0 to refer to the external drive and hd1 to refer to the internal drive.

# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE:  You have a /boot partition.  This means that
#          all kernel and initrd paths are relative to /boot/, eg.
#          root (hd0,0)
#          kernel /vmlinuz-version ro root=/dev/mapper/vg_asuslaptopcentos-lv_ro
ot
#          initrd /initrd-[generic-]version.img
#boot=/dev/sda1
default=0
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
title CentOS (2.6.32-358.6.2.el6.i686)
	root (hd0,0)
	kernel /vmlinuz-2.6.32-358.6.2.el6.i686 ro root=/dev/mapper/vg_asuslapto
pcentos-lv_root rd_NO_LUKS LANG=en_US.UTF-8 rd_NO_MD rd_LVM_LV=vg_asuslaptopcent
os/lv_swap SYSFONT=latarcyrheb-sun16 crashkernel=auto rd_LVM_LV=vg_asuslaptopcen
tos/lv_root  KEYBOARDTYPE=pc KEYTABLE=us rd_NO_DM rhgb quiet
	initrd /initramfs-2.6.32-358.6.2.el6.i686.img
title CentOS (2.6.32-358.el6.i686)
	root (hd0,0)
	kernel /vmlinuz-2.6.32-358.el6.i686 ro root=/dev/mapper/vg_asuslaptopcen
tos-lv_root rd_NO_LUKS LANG=en_US.UTF-8 rd_NO_MD rd_LVM_LV=vg_asuslaptopcentos/l
v_swap SYSFONT=latarcyrheb-sun16 crashkernel=auto rd_LVM_LV=vg_asuslaptopcentos/
lv_root  KEYBOARDTYPE=pc KEYTABLE=us rd_NO_DM rhgb quiet
	initrd /initramfs-2.6.32-358.el6.i686.img
title Windows 7
	rootnoverify (hd1,1)
	chainloader +1

What I learned:

Drive references may vary based on how the machine was booted.

You can’t just plug an external drive into a different machine and work with it, you may mess up the other machine.

Don’t change the Windows 7 boot loader, although you can use EasyBCD to recover. Maybe.

Taking the time to read the grub documentation is well worth the investment.

CentOS 6 / Windows 8 Dual-Boot on Different Drives

Please don’t consider this an authoritative post. To reach this point there were many, many reboots, reinstalls, and recoveries.

I bought a small ASUS tower from Best Buy and a 120GB solid-state drive.

I tried to install CentOS 6.4 over Windows 8, but the UEFI boot sequence prevented me from succeeding. Taking this a sign that there was value in Windows 8, I began to look into dual-booting.

Since I will be using CentOS for development and Windows 8 for testing (IE10), I wanted to put CentOS on the solid-state drive, and not modify the Windows 8 drive, other than that which was required to allow dual-booting.

The first few attempts assumed Windows would boot and allow me to choose CentOS, defaulting to CentOS. No matter what I did, this didn’t work. Right or wrong, I think Windows was unable to dual-boot to a drive other than the one it was on.

In the process, I lost the Windows recovery partitions installed by the manufacturer. This meant I had to reinstall Windows from a licensed MSDN disk. It also meant I lost the UEFI elements. But, in the end Windows 8 was booting and running.

I had to disable the UEFI only boot limitation in the BIOS. This may not be necessary.

The next step was to install CentOS, which I did using a USB stick and a network install. The stick was created with UNetBootin, which is really nice.

When the installer got to the part where it asked which drives should be used, I chose both the Windows and solid-state drives, and placed the boot loader on the Windows drive. This is because the Windows drive is identified in the UEFI BIOS as a boot device, and the solid-state disk isn’t. The solid-state device may be considered bootable now that the installation is complete, but there’s no reason to change what is working.

Once CentOS installed everything was fine. The only adjustment I made was to edit the /boot/grub/grub.conf file to change ‘Other’ to ‘Windows 8.’

This is the grub.conf file:

# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE:  You have a /boot partition.  This means that
#          all kernel and initrd paths are relative to /boot/, eg.
#          root (hd1,0)
#          kernel /vmlinuz-version ro root=/dev/mapper/vg_asustowercentos-lv_root
#          initrd /initrd-[generic-]version.img
#boot=/dev/sdc
default=0
timeout=5
splashimage=(hd1,0)/grub/splash.xpm.gz
hiddenmenu
title CentOS (2.6.32-358.6.1.el6.i686)
	root (hd1,0)
	kernel /vmlinuz-2.6.32-358.6.1.el6.i686 ro root=/dev/mapper/vg_asustowercentos-lv_root rd_NO_LUKS LANG=en_US.UTF-8 rd_LVM_LV=vg_asustowercentos/lv_root rd_NO_MD SYSFONT=latarcyrheb-sun16 rd_LVM_LV=vg_asustowercentos/lv_swap crashkernel=128M  KEYBOARDTYPE=pc KEYTABLE=us rd_NO_DM rhgb quiet
	initrd /initramfs-2.6.32-358.6.1.el6.i686.img
title CentOS (2.6.32-358.6.1.el6.i686)
	  root (hd1,0)
	  kernel /vmlinuz-2.6.32-358.6.1.el6.i686 ro root=/dev/mapper/vg_asustowercentos-lv_root rd_NO_LUKS LANG=en_US.UTF-8 rd_LVM_LV=vg_asustowercentos/lv_root rd_NO_MD SYSFONT=latarcyrheb-sun16 rd_LVM_LV=vg_asustowercentos/lv_swap crashkernel=128M  KEYBOARDTYPE=pc KEYTABLE=us rd_NO_DM rhgb quiet
	  initrd /initramfs-2.6.32-358.6.1.el6.i686.img
title Windows 8
	rootnoverify (hd0,0)
	chainloader +1

/dev/hd0 is the Windows drive
/dev/hd1 is the solid-state drive

Lessons I learned:

If you use gparted (http://gparted.sourceforge.net/), you can’t install Windows 8 on the new partitions.

I could create the UEFI partitions, but not the recovery partitions. But it wouldn’t work. I’m sure I missed some vital step. Every time. :)

The EasyBCD tool (http://neosmart.net/EasyBCD/) is really nice, but I couldn’t get it to do what I wanted. I think if you are going to put both operating systems on the same drive, it would be the way to go.

It costs $130 for the GeekSquad at BestBuy to restore the disk to its manufacturer state. I didn’t bother.

You can’t buy a Windows 8 recovery disk from the manufacturer (ASUS) at the time of this writing.

CentOS installs very fast on a solid-state drive. Thank goodness.

Creating the UEFI partitions for Windows 8 would probably take me a week, and even then, I’m not sure it would work. It’s very interesting.

UEFI = Universal Extensible Firmware Interface

I should have made a recovery disk for Windows before I started.

Windows 8 is nice.

Window-X (holding the Windows key and clicking X) gets you the admin menu, which includes the command line and disk management utilties.

Windows 8 has auto-repair, but it didn’t work in my case.

It often takes less time to reinstall than to identify and correct a problem. That’s a fine strategy if you don’t need to know too much. In my case, the goal was dual-boot - not a thorough understanding of the boot load process across two operating systems.

Adjusting the screen resolution under CentOS 6

With sincere thanks to the link above, this is how you can adjust the screen resolution under CentOS 6.

Run this command (with the appropriate resolution):

cvt 1920 1080

You’ll get output similar to this:

# 1920x1080 59.96 Hz (CVT 2.07M9) hsync: 67.16 kHz; pclk: 173.00 MHz
Modeline “1920x1080_60.00″ 173.00 1920 2048 2248 2576 1080 1083 1088 1120 -hsync +vsync

Copy the modeline and paste it after –newmode, like so:

xrandr --newmode "1920x1080_60.00" 173.00 1920 2048 2248 2576 1080 1083 1088 1120 -hsync +vsync

Then assign the new mode to the device:

xrandr --addmode VGA-1 "1920x1080_60.00"

This was done on a clean stock CentOS 6.4 installation, no custom drivers.

To get the settings to persist across sessions, I created /etc/gdm/PostLogin/Default
like so:

#!/bin/sh
#
if [ -f "$HOME/.gdm/PostLogin/Default" ];
then
	exec -l "$SHELL" -c "$HOME/.gdm/PostLogin/Default"
fi;

Under the account, I add the Default file:

xrandr --newmode "1920x1080_60.00"  173.00  1920 2048 2248 2576  1080 1083 1088 1120 -hsync +vsync
xrandr --addmode VGA-1 "1920x1080_60.00"
xrandr --output VGA-1 --mode "1920x1080_60.00"

Be sure to grant execute permissions on both /etc/gdm/PostLogin/Default and $HOME/.gdm/PostLogin/Default.

Adding nVidia drivers didn’t help, adding hplip didn’t help. There is a Tripp-Lite KVM switch. This was the answer.

And, it looks great.